🔎 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
https://www.typescriptlang.org/play/?#code/FAUwHgDg9gTgLgAgDYkQQwFwIBQB4AqAfNgJQIC8hC+C4cIAdgCYDOCABgCQDeA5GrwQAyBNwSYEARgQBfGewQB+KQiwAmMuQQMArkiQBCANyhIsRCkQAjLHiKkKVGnUasOPfoJFiJ0uQuVpdU1tPUMTYDQKBCsjIA
💻 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.
🔎 Search Terms
brand branded tag tagged template string not assignable extends different type name unrelated
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/FAUwHgDg9gTgLgAgDYkQQwFwIBQB4AqAfNgJQIC8hC+C4cIAdgCYDOCABgCQDeA5GrwQAyBNwSYEARgQBfGewQB+KQiwAmMuQQMArkiQBCANyhIsRCkQAjLHiKkKVGnUasOPfoJFiJ0uQuVpdU1tPUMTYDQKBCsjIA
💻 Code
🙁 Actual behavior
Typescript error:
🙂 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.