-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Bug Report
🔎 Search Terms
- this index
🕗 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'].
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug