We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"template cartesian product", "cross-product of same union", "template string multiple"
behaves exactly the same
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABFApgZygCgG4EMA2AXIgEQCCFJiAPqQEIMkCUiA3gLABQiiECGiAE4ooiALyIABgBJWefAF8AtLPkLJiXGl78oAbi48A9EcQAVAJ4AHFIhhhgKQcIAmm7eQpKKZKrU9kSgx0fvQM3pQ0YXRBjIaIJnZgGCi4bnDApD4RvlEkwbEhXApAA
function test(val: "AAA" | "BBB") { const ret = `${val}-${val}` as const; // Type inferred as "AAA-AAA" | "AAA-BBB" | "BBB-AAA" | "BBB-BBB" // instead of "AAA-AAA" | "BBB-BBB" }
Type inferred as "AAA-AAA" | "AAA-BBB" | "BBB-AAA" | "BBB-BBB" when a union is used twice in same template string.
It should be possible to infer that ret can only be "AAA-AAA" | "BBB-BBB"
ret
"AAA-AAA" | "BBB-BBB"
This issue seems similar: #57427
The text was updated successfully, but these errors were encountered:
search in:title template literal union
in:title template literal union
Duplicate of #49132
Sorry, something went wrong.
No branches or pull requests
🔎 Search Terms
"template cartesian product", "cross-product of same union", "template string multiple"
🕗 Version & Regression Information
behaves exactly the same
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABFApgZygCgG4EMA2AXIgEQCCFJiAPqQEIMkCUiA3gLABQiiECGiAE4ooiALyIABgBJWefAF8AtLPkLJiXGl78oAbi48A9EcQAVAJ4AHFIhhhgKQcIAmm7eQpKKZKrU9kSgx0fvQM3pQ0YXRBjIaIJnZgGCi4bnDApD4RvlEkwbEhXApAA
💻 Code
🙁 Actual behavior
Type inferred as "AAA-AAA" | "AAA-BBB" | "BBB-AAA" | "BBB-BBB" when a union is used twice in same template string.
🙂 Expected behavior
It should be possible to infer that
ret
can only be"AAA-AAA" | "BBB-BBB"
Additional information about the issue
This issue seems similar: #57427
The text was updated successfully, but these errors were encountered: