🔎 Search Terms
"type identity check", "type equality check", "conditional type elimination", "generic simplification", "dependent conditional types", "eager evaluation", "deferred evaluation", "conditional type simplification", "deferred conditional type evaluation", "dependent conditional type", "generic function", "generic function with conditional return type", "type equality check", "dependent types", "dependent return type"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "common bugs that aren't bugs"
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBDAnmYcCiBHArgQwDYDOAPACoA0cAqgHxwC8AUHHABREAa1LAlPbe3FAxgAOwAmBOCTgB+OAEY4ALjgAmXkNES4HLrzr9BIYeMmVZC5WqbMLMKFmA3mKgGb4CwANwMGSFHAASsBgUBDyRABqtHTo2B5EANqRALoUifIp1L7+qMGhEKpRMXCJySkpRibaiQCWIq7AUHAA8pVymLiERC3pmbQqIsAAbk0+DGLAAMZ4OFCow3NwBAAWEFh4YgBCwCQOwPIq+WER8tQ+kzNzC0ur65s7e46qRyFhRWfjl7PzcIvNdw222AADEPAdXgUIjgRIhzhNpj8bgC1kCdmDCMAXkE3oUiDC4eNAQ9dvtFLF7I4fMTgU8sfQEPsiaiSRjPOS4O5MdSWcC2fTYlzPD4gA
💻 Code
export type Equals<T, U> =
(<X>() => X extends T ? 1 : 2) extends <X>() => X extends U ? 1 : 2
? true
: false;
type Repro1<V> = Equals<[V], [1]>
type Repro2<V> = [[V]] extends [infer O] ? Equals<O, [1]> : never;
declare var shouldBeTrue1: Repro1<1>;
declare var shouldBeTrue2: Repro2<1>;
declare var shouldBeFalse1: Repro1<any>;
declare var shouldBeFalse2: Repro2<any>;
shouldBeTrue1 = true;
shouldBeTrue2 = true;
shouldBeFalse1 = false;
shouldBeFalse2 = false;
🙁 Actual behavior
true is not assignable to shouldBeTrue1 and shouldBeTrue2 as their type is false.
🙂 Expected behavior
true should be assignable to shouldBeTrue1 and shouldBeTrue2
Additional information about the issue
No response
🔎 Search Terms
"type identity check", "type equality check", "conditional type elimination", "generic simplification", "dependent conditional types", "eager evaluation", "deferred evaluation", "conditional type simplification", "deferred conditional type evaluation", "dependent conditional type", "generic function", "generic function with conditional return type", "type equality check", "dependent types", "dependent return type"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBDAnmYcCiBHArgQwDYDOAPACoA0cAqgHxwC8AUHHABREAa1LAlPbe3FAxgAOwAmBOCTgB+OAEY4ALjgAmXkNES4HLrzr9BIYeMmVZC5WqbMLMKFmA3mKgGb4CwANwMGSFHAASsBgUBDyRABqtHTo2B5EANqRALoUifIp1L7+qMGhEKpRMXCJySkpRibaiQCWIq7AUHAA8pVymLiERC3pmbQqIsAAbk0+DGLAAMZ4OFCow3NwBAAWEFh4YgBCwCQOwPIq+WER8tQ+kzNzC0ur65s7e46qRyFhRWfjl7PzcIvNdw222AADEPAdXgUIjgRIhzhNpj8bgC1kCdmDCMAXkE3oUiDC4eNAQ9dvtFLF7I4fMTgU8sfQEPsiaiSRjPOS4O5MdSWcC2fTYlzPD4gA
💻 Code
🙁 Actual behavior
trueis not assignable toshouldBeTrue1andshouldBeTrue2as their type isfalse.🙂 Expected behavior
trueshould be assignable toshouldBeTrue1andshouldBeTrue2Additional information about the issue
No response