microsoft / microsoft/TypeScript
Computing constraint of conditional type by replacing contravariant infer variables with their constraints is unsound
Offen
@ahejlsberg arbeitet bereits daran.
Seit 07.9.2018.
Bug
Domain: Conditional Types
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
TypeScript Version: master (8f654f0)
Search Terms:
conditional type assignability assignable constraint contravariant infer variable parameter unsound
Code
type Foo<A> = [A] extends [[infer B]] ? (arg: B) => void : never;
function fortyTwo<A>(x: Foo<A>) { x(42); }
fortyTwo<[string]>((arg: string) => console.log(arg.slice()));
Expected behavior: Compile error on x(42).
Actual behavior: Successful compilation and runtime error.
Playground Link: link
Related Issues: #26933
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.