Skip to content

Conditional type on type argument reports different value when assigned to vs assigned fromΒ #52021

Open
@calebmer

Description

@calebmer

Bug Report

πŸ”Ž Search Terms

Conditional type, assigned to, assigned from, type arguments

πŸ•— Version & Regression Information

  • This is a crash: no
  • This changed between versions 4.2.3 and 4.3.5

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

function test<T extends {}>() {
    type T1 = T extends {} ? true : false;
    type T2 = T & {} extends {} ? true : false;

    const t1a: T1 = true; // Errors?
    const t2a: T2 = true; // Ok

    const t1b: true = make<T1>(); // Ok
    const t2b: true = make<T2>(); // Errors?
}

declare function make<T>(): T;

πŸ™ Actual behavior

  1. true is not assignable to T1.
  2. T2 is not assignable to true.

πŸ™‚ Expected behavior

  1. true is assignable to T1.
  2. T2 is assignable to true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InvestigationThis issue needs a team member to investigate its status.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions