🔎 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.
🔎 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
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.3#code/C4TwDgpgBARgrgcwDwBUB8UC8UVQgD2AgDsATAZygHsYArCAY2CgH4oAKXAosy4uALYwIAJ1Y4oALigAzAIYAbchACUU2YuUBuAFClGCuSOgA3I1GNgRVdfGT8hoqADIoAbyhzpARigBfNF1Layx3P09KOWIQHSA
💻 Code
🙁 Actual behavior
anyis not assignable toreproas it hasnevertype.🙂 Expected behavior
anyshould be assignable toreprobecause it should havenumber & {a:1}type.Additional information about the issue
In TypeScript playground this bug occurs starting at TypeScript version 3.6.2 and above.