Skip to content

Use return type as an inference location #11152

Closed

Description

From #11054

interface FolderContentItem{
    type: 'folder' | 'file';
}

let a:FolderContentItem[] = [];
a = [1,2,3,4,5].map(v=>({type:'folder'}))

Today this is an error without casting "folder" to the literal type. We have a contextual type coming from a that is not being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

FixedA PR has been merged for this issueNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions