Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@mattmccutchen

Description

@mattmccutchen
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional typesThe issue relates to conditional types

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.