Description
π Search Terms
brand branded tag tagged template string not assignable extends different type name unrelated
π Version & Regression Information
- This changed between versions 5.0.4 and 5.1.6
β― Playground Link
π» Code
export let a: (<T>() => T extends `${'a' & { a: 1 }}` ? 1 : 2) = null!;
export let b: (<T>() => T extends `${'a' & { a: 1 }}` ? 1 : 2) = null!;
a = b; // β Error!
π Actual behavior
Typescript error:
Type
'<T>() => T extends `${"a" & { a: 1; }}` ? 1 : 2'
is not assignable to type
'<T>() => T extends `${"a" & { a: 1; }}` ? 1 : 2'
.
Two different types with this name exist, but they are unrelated.
π Expected behavior
No error
Additional information about the issue
I would expect that, as a general principle, any type which is copy-and-pasted from one place to another should be assignable to itself. (With the exception of unique symbol
, since by design it's supposed to not do what I just said.) This is perhaps the most lax notion of assignability that could possibly exist, I would think.
Note that, as soon as I remove either the outer template or the inner brand, assignability works as expected once again.