Microsoft/TypeScript

Union tuple type in rest argument can't accpect less argument.

Open

#48,663 建立於 2022年4月13日

在 GitHub 查看
 (4 留言) (3 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: check: Variance RelationshipsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Bug Report

🔎 Search Terms

source has but target allows only

🕗 Version & Regression Information

  • This is a crash

⏯ Playground Link

Playground link with relevant code

💻 Code

const func: (...args: [number, string] | [string, number]) => void = (item) => { }

🙁 Actual behavior

throw error

Type '(item: string | number) => void' is not assignable to type '(...args: [number, string] | [string, number]) => void'.
  Types of parameters 'item' and 'args' are incompatible.
    Type '[number, string] | [string, number]' is not assignable to type '[item: string | number]'.
      Type '[number, string]' is not assignable to type '[item: string | number]'.
        Source has 2 element(s) but target allows only 1.

🙂 Expected behavior

no error

貢獻者指南