-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 2.2.2
Code
function getName(id: number) {
return {
1: 'one',
2: 'two',
}[id] || 'something else';
}
Expected behavior:
{1: 'one'}[id]
type should be string | undefined
So I would expect the return type to be inferred as string.
Actual behavior:
Element implicitly has an 'any' type because type '{ 1: string; 2: string; }' has no index signature.
vladimir-tikhonov, monolithed, rohmanhm, niedzielski, grant and 32 morefregante
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript