-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Closed
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: typescript@2.8.0-dev.20180220, typescript@2.7.2
Code
declare const dict: { [K: string]: number | undefined };
function foo<S extends string>(betSpot: S): number {
const value = dict[betSpot];
return value ? value : 0;
// ~~~~~~~~~~~~~~~~~~~~~~~~~
}Expected behavior:
No error
Actual behavior:
Type '{ [K: string]: number | undefined; }[S]' is not assignable to type 'number'.
Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
Related Issues:
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created