Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computing constraint of conditional type by replacing contravariant infer variables with their constraints is unsound #26945

Open
mattmccutchen opened this issue Sep 6, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript
Milestone

Comments

@mattmccutchen
Copy link
Contributor

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

@jack-williams
Copy link
Collaborator

What would be the fix for this, substituting the lower bound (never) instead, or just failing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants