-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
π Search Terms
Readonly<[...unknown[], infer L]>
and readonly [...unknown[], infer L]
exhibit inconsistent behavior.
π Version & Regression Information
β― Playground Link
π» Code
type A = Readonly<[...unknown[], unknown]>
// ^? type A = readonly [...unknown[], unknown]
type B = readonly [...unknown[], unknown]
// ^? type B = readonly [...unknown[], unknown]
type T1 = ['a', 'b', 'c'] extends readonly [infer H, ...unknown[]] ? H : never
// ^? type T1 = 'a'
type T2 = ['a', 'b', 'c'] extends Readonly<[infer H, ...unknown[]]> ? H : never
// ^? type T2 = 'a'
type T3 = ['a', 'b', 'c'] extends readonly [...unknown[], infer L] ? L : never
// ^? type T3 = 'c'
type T4 = ['a', 'b', 'c'] extends Readonly<[...unknown[], infer L]> ? L : never
// ^? type T4 = unknown
// Actual: unknown
// Expected: 'c'
π Actual behavior
π Expected behavior
Infer the correct type.
Additional information about the issue
No response
craigphicks, robpalme and realrickren
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