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'].