🔎 Search Terms
"infer", "regression", "wide", "narrow"
🕗 Version & Regression Information
- This changed between versions 5.9.3 and 6.0.2
- This changed in commit or PR ???
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about YES
- I was unable to test this on prior versions because N/A
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.2#code/C4TwDgpgBAggQlAvFA5DFUA+q4oNwBQBAxgPYB2AzsFACICiAYjAKoAyAKgFywLJr4ixADYBDSpSgBhKAG8CUOkjpNWnQgqgBbCMAAWpACYAKAJRzNiygHcAlsGJ7j+25QB0tc-MU+oxcdACPABGAE4QogDWhL6K-pSBuCHhUTE+AL6amelAA
💻 Code
type AB = 'A' | 'B';
const DEFAULT: AB = 'A';
class C {
D = DEFAULT;
method() {
switch(this.D) {
case 'A': break;
case 'B': break;
}
}
}
🙁 Actual behavior
C.D infers to "A"
🙂 Expected behavior
C.D infers to AB
Additional information about the issue
Somewhat common occurrence in Angular code.
Hundreds of instances of this class of error in Google.
🔎 Search Terms
"infer", "regression", "wide", "narrow"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.2#code/C4TwDgpgBAggQlAvFA5DFUA+q4oNwBQBAxgPYB2AzsFACICiAYjAKoAyAKgFywLJr4ixADYBDSpSgBhKAG8CUOkjpNWnQgqgBbCMAAWpACYAKAJRzNiygHcAlsGJ7j+25QB0tc-MU+oxcdACPABGAE4QogDWhL6K-pSBuCHhUTE+AL6amelAA
💻 Code
🙁 Actual behavior
C.Dinfers to"A"🙂 Expected behavior
C.Dinfers toABAdditional information about the issue
Somewhat common occurrence in Angular code.
Hundreds of instances of this class of error in Google.