Closed
Description
🔎 Search Terms
5.3 const type parameter const like array readonly
🕗 Version & Regression Information
EDIT: replace my unintuitive attempt at indicating a range of versions for clarity - This changed between versions 5.0.4, 5.1.6, 5.2.2 and 5.3.3, 5.4.0-dev.20240129
- This changed between versions 5.2.2 and 5.3.3
⏯ Playground Link
💻 Code
const previousBehavior = <const T extends readonly string[]>(t: T) => t;
const testPrevious = previousBehavior(["foo"]);
// ^?
const newBehavior = <const T extends string[]>(t: T) => t;
const testNew = newBehavior(["foo"]);
// ^?
🙁 Actual behavior
newBehavior
is able to infer t
as ["foo"]
on 5.3+.
🙂 Expected behavior
I would expect newBehavior
to infer t
as string[]
as it did on previous versions and a readonly
modifier must be used to infer ["foo"]
(well, technically, readonly ["foo"]
), as is mentioned is required on the pull request and announcement that introduced this feature.
Additional information about the issue
I'm curious if this is expected behavior and can be relied upon in future versions. Thanks!
Metadata
Metadata
Assignees
Labels
No labels