Skip to content

[TS 5.4.0-beta] Tuple type members being preservedΒ #57389

Closed
@acutmore

Description

@acutmore

πŸ”Ž Search Terms

spread tuple type narrowing

πŸ•— Version & Regression Information

  • This changed between versions 5.3.3 and 5.4.0-beta
  • This changed in 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

declare function getT<T>(): T;

Promise.all([getT<string>(), ...getT<any>()])
   .then((result) => {
        // ^?
      const head = result[0];       // 5.3: any, 5.4: string
         // ^?
      const tail = result.slice(1); // 5.3 any, 5.4: unknown[]
         // ^?
      tail satisfies string[];     // <-- new error in 5.4
   });

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.

Metadata

Metadata

Labels

DocsThe issue relates to how you learn TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions