-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Search Terms
const modifier, generics, tuple types
π Version & Regression Information
It shows up just in the nightly version because const modifiers for generics will be available from TS 5.0
β― Playground Link
Playground link with relevant code
π» Code
declare function inners<const T extends readonly any[]>(...args: readonly [unknown, ...T, unknown]): T;
const test = inners(1,2,3,4,5);π Actual behavior
T is inferred as [number, number, number] instead of readonly [2,3,4]. There are other ways to write this function by avoiding tuple types at all, but it is a nice example to show that that the constness introduced by the const modifier seems to be lost when tuple types come into play, even with the readonly modifier.
π Expected behavior
T inferred as readonly [2,3,4]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue