Microsoft/TypeScript

Omitting a property from tuple breaks destruction

開放

#54,371 建立於 2023年5月24日

 (17 則留言) (0 個反應) (0 位負責人)TypeScript (13,395 個分叉)batch import
BugDomain: Mapped TypesHelp Wanted

倉庫指標

星標
 (108,860 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Bug Report

🔎 Search Terms

tuple omit property Searched in Bing and Github issues but I found nothing

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Link

💻 Code

const foo = [1, "2"] as const
const [a, b] = foo // everything works well, a is number and b is string

const bar = [1, "2"] as Omit<[number, string], "at">
const [c, d] = bar // Oops! c and d are string | number now

🙁 Actual behavior

c and d are both string | number

🙂 Expected behavior

a and b should have correct type

貢獻者指南