Skip to content

The behavior is different for two code that looks the same #30988

Closed
@kgtkr

Description

@kgtkr

TypeScript Version: 3.4.2

Search Terms:
conditional type

Code

OK

type F<X> = <T>() => T extends X ? 1 : 2;

declare const x: F<any>;
const y: F<number> = x;

Error

declare const x: <T>() => T extends any ? 1 : 2;
const y: <T>() => T extends number ? 1 : 2 = x;

Expected behavior:
The two codes do the same thing

Actual behavior:
Different behavior

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions