ember-cli-typescript
ember-cli-typescript copied to clipboard
Different behavior when using a private vs a public property
Which package(s) does this problem pertain to?
- [x] @types/ember
- [x] @types/ember__object
Having a:
class extends Controller {
private foo?: string;
public bar?: string;
public clear() {
this.set('foo', undefined);
this.set('bar', undefined);
}
}
Leads to a single warning error TS2345: Argument of type '"foo"' is not assignable to parameter of type 'keyof this'.. I can't begin to imagine why is the warning there for private fields but not for public ones? Is this a bug in Ember's type definitions or in TypeScript? Or is this by design?
This used to be a limitation of our type definitions, but it should have been fixed when we resolved #226 via definitelytyped/definitelytyped#28282.
@mike-north or @dwickern do you have any idea what the state is on this?
This is by design according to https://github.com/Microsoft/TypeScript/issues/13543