-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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']
.
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