Microsoft/TypeScript

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

Open

#48.663 geöffnet am 13. Apr. 2022

Auf GitHub ansehen
 (4 Kommentare) (3 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: check: Variance RelationshipsHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide