-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: nightly (2.2.0-dev.20161219)
Code
type Foo<T, F extends keyof T> = {
pf: {[P in F]?: T[P]},
pt: {[P in T]?: T[P]}, // note: should be in keyof T
};
type O = {x: number, y: boolean};
let o: O = {x: 5, y: false};
let f: Foo<O, 'x'> = {
pf: {x: 7},
pt: {x: 7, y: false},
};
Expected behavior:
Compiling only the first type declaration produces the following expected error:
$ node node_modules/typescript/bin/tsc test.ts
test.ts(4,16): error TS2322: Type '{}' is not assignable to type 'string'.
test.ts(4,21): error TS2536: Type 'P' cannot be used to index type 'T'.
Actual behavior:
Compiling the whole example with a clean nightly install without tsconfig
produces:
$ node node_modules/typescript/bin/tsc test.ts
C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:49834
throw e;
^
TypeError: Cannot read property 'flags' of undefined
at getModifiersTypeFromMappedType (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:23125:60)
at resolveMappedTypeMembers (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:23068:49)
at resolveStructuredTypeMembers (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:23153:25)
at getPropertyOfType (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:23307:32)
at C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:28345:47
at applyToContextualType (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:28321:24)
at getTypeOfPropertyOfContextualType (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:28344:20)
at getContextualTypeForObjectLiteralElement (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:28368:40)
at getContextualType (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:28442:28)
at checkExpressionForMutableLocation (C:\Users\...\Documents\TCM\git\tmp\node_modules\typescript\lib\tsc.js:31213:69)
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue