Equivalent arguments typed with tuples aren't assignable to the same functions with overloads when the same function is recursively referenced
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- compilers
Direzione di ricerca
Inizia con la riproduzione in TypeScript Playground collegata nell’issue e analizza il comportamento di assegnabilità ricorsiva tra funzioni con argomenti tuple e funzioni sovraccariche. Il lavoro è completato quando l’assegnazione mostrata ha esito positivo senza errori, mantenendo al contempo il controllo corretto delle firme ricorsive.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
🔎 Search Terms
arguments, overloads, function, tuple
🕗 Version & Regression Information
All versions with support for tuple arguments (upto v4.5.0-dev.20210815).
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about function overloading (there is nothing in the FAQ about tuples)
⏯ Playground Link
Playground link with relevant code
💻 Code
type START = 0
type DATA = 1
type Args<In, Out> =
| [t: START, other: FnWithArgs<Out, In>]
| [t: DATA]
type FnWithArgs<In, Out> = (...args: Args<In, Out>) => void
interface FnWithOverloads<In, Out> {
(t: START, other: FnWithOverloads<Out, In>): void;
(t: DATA): void;
}
declare const withArgs: FnWithArgs<1, 2>
// these should be assignable to one another, but aren't:
const assertion: FnWithOverloads<1, 2> = withArgs
🙁 Actual behavior
Two types that should be functionally equivalent aren't assignable to one another:
Type 'FnWithArgs<1, 2>' is not assignable to type 'FnWithOverloads<1, 2>'.
Types of parameters 'args' and 't' are incompatible.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type 'Args<1, 2>'.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type '[t: 0, other: FnWithArgs<2, 1>]'.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'FnWithOverloads<2, 1>' is not assignable to type 'FnWithArgs<2, 1>'.
Types of parameters 't' and 'args' are incompatible.
Type 'Args<2, 1>' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Type '[t: 1]' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Source has 1 element(s) but target requires 2.
I've tried simplifying the example, and this issue doesn't seem to occur when the parameters of the function don't reference themselves in their signature.
🙂 Expected behavior
No error, types should be assignable to one another.
Related issues
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/TypeScript
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
microsoft/TypeScript#64322 · 2 commenti · 1 reazione · 2 assegnatari ·
-
Possible Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/TypeScript#64278 · 1 commento · 1 reazione ·
-
Docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
microsoft/TypeScript#64118 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
microsoft/TypeScript#64094 ·
-
Docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/TypeScript#63959 · 5 commenti ·
Tutte le issue di microsoft/TypeScript
Issue simili
-
optimization optimization:agents-md-curator
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
blinklabs-io/bursa#904 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 commenti ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100