Closed
Description
TypeScript Version: v3.1.0-dev.20180804
Search Terms: private symbol property this generic parameter
Code
type F<T> = (this: T) => void;
interface IClassA {
hello(): F<this>;
}
const p1 = Symbol("class:a:p1");
class A
implements IClassA {
private [p1]: string;
public hello(): F<this> {
return function(): void {
this[p1] = "123";
delete this[p1];
return;
};
}
}
// Here reports an error saying "Property '[p1]' is missing in type 'IClassA'"
let a: IClassA = new A();
Expected behavior:
I think it should work well without any error reporting.
Actual behavior:
It reports an error like this:
[ts]
Type 'A' is not assignable to type 'IClassA'.
Types of property 'hello' are incompatible.
Type '() => F<A>' is not assignable to type '() => F<IClassA>'.
Type 'F<A>' is not assignable to type 'F<IClassA>'.
The 'this' types of each signature are incompatible.
Type 'IClassA' is not assignable to type 'A'.
Property '[p1]' is missing in type 'IClassA'.
[p1
is a private property of the class, how could it lead a conflict with an implemented interface?
Playground Link:
Related Issues: