Bug Report
🔎 Search Terms
🕗 Version & Regression Information
This changed between versions 3.3.3 and 3.5.1, and it keeps the behavior since then to the current latest version (at least 4.7.3).
⏯ Playground Link
Playground link with relevant code
💻 Code
class Test {
a = '';
b = 0;
test() {
const a: this['a'] = ''; // ok
const b: this['b'] = 0; // ok
const c: Test['a' | 'b'] = ''; // ok
const d: this['a' | 'b'] = ''; // fail
}
}
🙁 Actual behavior
Type 'string' is not assignable to type 'this["a"] & this["b"]'.
Type 'string' is not assignable to type 'this["b"]'.
Type 'string' is not assignable to type 'number'.(2322)
🙂 Expected behavior
I expect this['a' | 'b'] to be string | number in this example, thus accepting the assignment of '' to it, just like Test['a' | 'b'].
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
This changed between versions 3.3.3 and 3.5.1, and it keeps the behavior since then to the current latest version (at least 4.7.3).
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
I expect
this['a' | 'b']to bestring | numberin this example, thus accepting the assignment of''to it, just likeTest['a' | 'b'].