Skip to content

branded type erroneously replaced with never in a conditional type #63459

@carljohnsonnewhampshire-hue

Description

🔎 Search Terms

"branded types", "branded type in a conditional type", "conditional type", "type inference", "checking for branded types", "branded type conditionals", "type conditional", "conditional type", "branded type inference", "branded type detection", "branded primitive types", "conditional type returns never for branded types"

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "This conditional type returns never when it should return the true branch."

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.3#code/C4TwDgpgBARgrgcwDwBUB8UC8UVQgD2AgDsATAZygHsYArCAY2CgH4oAKXAosy4uALYwIAJ1Y4oALigAzAIYAbchACUU2YuUBuAFClGCuSOgA3I1GNgRVdfGT8hoqADIoAbyhzpARigBfNF1Layx3P09KOWIQHSA

💻 Code

type bug<T> = T extends object ? (T extends number ? T : false) : false;
declare var repro : bug<number & { a: 1 }>;
repro = {} as any

🙁 Actual behavior

any is not assignable to repro as it has never type.

🙂 Expected behavior

any should be assignable to repro because it should have number & {a:1} type.

Additional information about the issue

In TypeScript playground this bug occurs starting at TypeScript version 3.6.2 and above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions