You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So how [string, ...any[]] was converted into [string, ...unknown[]] here? The reason is that now instantiateMappedTupleType has this ?? unknownType fallback when computing newElementTypes.
But it's not consistent with how mapped types continue to work today:
typeIdentity<T>={[KinkeyofT]: T[K]}typeResult=Identity<[string, ...any[]]>// ^? type Result: [string, ...any[]]
So the problem is that what we see in the original repro is actually not a true any but rather an errorType. And if we play around with it we can see the change in the behavior:
typeIdentity<T>={[KinkeyofT]: T[K]}typeErrorType={}['prop']typeResult=Identity<[string, ...ErrorType[]]>// ^? 5.3: any (displayed as `any` but it's an `errorType`) 5.4: [string, ...unknown[]]
The PR to which this has been bisected improves the situation (the output should be a tuple and not an any/errorType) but accidentally maps the thing to [string, ...unknown[]].
Why the errorType has crawled into all of this though? Well, I already have a fix for this π : #57116
acutmore
changed the title
[TS 5.4.0-beta] Tuple type members being perserved
[TS 5.4.0-beta] Tuple type members being preserved
Feb 13, 2024
π Search Terms
spread tuple type narrowing
π Version & Regression Information
5.4.0-dev.20240120
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-beta#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwHMQMAVAHhID4AKASgC54SBuAKFYAUYcBbLAZxAA6KBAjUA2kVJl+GGFlQEatADTwhm6eSioAnioC6tVvDNCMACxCpq1OP2QQMteAF5K8AN6mzfswD0AfAAegD8vv5geHLw1lDA7vAOThgSAAyGzP5+QfAArEIAzIy6euqFACyMcgpKkTnweeENZtGosRhQWBBJKc5C-BBYYCDUAIy02XmFRfBlFULV8GgA1qg4AO6oEoat-s0RjV098PxQ2PyIWCD8Z-KKBLvZB8FkALTv8Kggm-AgMG4MHgigKS0iAF8pqwgA
π» Code
Additional information about the issue
More of a 'change report' than a 'bug report', I don't think this was part of the 5.4 beta announcement.
The text was updated successfully, but these errors were encountered: