You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// a.tstypePoint={x: number;y: number;moveBy(dx: number,dy: number): void;}letp: Point|null;p={x: 10,y: 20,moveBy(dx,dy){this.x+=dx;// this has type Pointthis.y+=dy;// this has type Point}};
TypeScript Version: nightly (2.3.0-dev.20170307)
Code
and the
tsconfig.json
isExpected behavior:
tsc
compiles a.ts without any error.Actual behavior:
It reports:
Propose
I think this is a bug because in most situations we won't want a "nullable"
this
in a object literal's member functions.It's encouraging that #14141 has been merged, but there still seems to be some inconvenient rules.
In the case above, a better design might be:
p
null
andundefined
)ThisType
for the object literal's member functions.The text was updated successfully, but these errors were encountered: