You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TS2.7.1 Test2 does not work at all producing the following error:
[ts]
Argument of type '{ columns: ({ property: "hello"; } | { property: "goodbye"; })[]; }' is not assignable to parameter of type 'ITable<{ hello: any; }>'.
Types of property 'columns' are incompatible.
Type '({ property: "hello"; } | { property: "goodbye"; })[]' is not assignable to type 'IColumn<{ hello: any; }, "hello">[] | "hello"[]'.
Type '({ property: "hello"; } | { property: "goodbye"; })[]' is not assignable to type '"hello"[]'.
Type '{ property: "hello"; } | { property: "goodbye"; }' is not assignable to type '"hello"'.
Type '{ property: "hello"; }' is not assignable to type '"hello"'.
@charsleysa,
Have you tried to get feedback in a specific forum? stackoverflow.com will give you better and faster feedback for your problem. Check there if it's just a code error.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.7.1
Search Terms: inferred generic key type index
Code
Expected behavior:
Both
Test1
andTest2
should correctly work with correct type inference on both sides.Actual behavior:
Both
Test1
andTest2
work correctly in TS2.6.2In TS2.7.1
Test1
works correctly but is missing type inference on right side (hovering overcreateTable
produces:In TS2.7.1
Test2
does not work at all producing the following error:Playground Link:
http://www.typescriptlang.org/play/#src=interface%20IColumn%3CRow%2C%20Name%20extends%20keyof%20Row%3E%20%7B%0D%0A%20%20%20%20property%3F%3A%20Name%3B%0D%0A%20%20%20%20type%3F%3A%20Row%5BName%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20ITable%3CRow%3E%20%7B%0D%0A%20%20%20%20columns%3A%20Array%3CIColumn%3CRow%2C%20keyof%20Row%3E%3E%20%7C%20Array%3Ckeyof%20Row%3E%3B%0D%0A%7D%0D%0A%0D%0Adeclare%20function%20createTable%3CT%3E(definition%3A%20ITable%3CT%3E)%3A%20T%3B%0D%0A%0D%0A%2F%2F%20Test1%0D%0Aconst%20t1%3A%20%7B%20hello%3A%20string%2C%20goodbye%3A%20boolean%20%7D%20%3D%20createTable(%7B%0D%0A%20%20%20%20columns%3A%20%5B'hello'%2C%20'goodbye'%5D%0D%0A%7D)%3B%0D%0A%0D%0A%2F%2F%20Test2%0D%0Aconst%20t2%3A%20%7B%20hello%3A%20string%2C%20goodbye%3A%20boolean%20%7D%20%3D%20createTable(%7B%0D%0A%20%20%20%20columns%3A%20%5B%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20property%3A%20'hello'%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20property%3A%20'goodbye'%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%0D%0A%7D)%3B
Related Issues:
Possibly
#21553
#21529
The text was updated successfully, but these errors were encountered: