-
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: 3.1.0-dev.20180810
Code
const f = <T extends { [K0 in K]: string; } & { cool: string; }, K extends keyof T>(t: T, k: K) =>
{
const s: string = t[k];
};
Expected behavior: Successful compilation
Actual behavior: I get the following error:
error TS2322: Type 'T[K]' is not assignable to type 'string'.
const s: string = t[k];
~
Playground Link: Link
Additional Notes: This compiles successfully (link):
const f = <T extends { [K0 in K]: string; } & { cool: string; }, K extends keyof T>(t: T, k: K) =>
{
const s: string = t['cool'];
};
as does this (link):
const f = <T extends { [K0 in K]: string; }, K extends keyof T>(t: T, k: K) =>
{
const s: string = t[k];
};
sethduncan, CharlesTaylor7, Methuselah96, sehcheese and johntholland
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