-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Bug Report
π Search Terms
narrowing generic parameter
π Version & Regression Information
- This changed between versions 4.4.3 and 4.6.4
β― Playground Link
Playground link with relevant code
Changing the version to 4.4.4 works
π» Code
Reduced example, the code on the playground is an actual function from our codebase that used to work fine.
type TimestampColumns<T> = {
[K in keyof T]: T[K] extends Date ? K : never
}[keyof T];
function getTimestamp<Row extends Record<string, unknown>, K extends TimestampColumns<Row>>(
row: Row,
timestampColumn: K,
): number {
const date: Date = row[timestampColumn]; // This used to work;
return date.valueOf();
}
π Actual behavior
The code should compile with no warnings or errors.
π Expected behavior
Fails with error Type 'Row[K]' is not assignable to type 'Date'.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created