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
Both (1) and (2) should complain about length not existing on number
Actual behavior:
(1) correctly complains: foo.ts(3,30): error TS2339: Property 'length' does not exist on type 'number'. But there is no error for (2).
Adding --noImplicitAny doesn't change the result.
Adding --noImplicitThis gives foo.ts(4,36): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. which confirms that this in (2) is getting inferred as any
The text was updated successfully, but these errors were encountered:
Same root cause as #4241 - due to the arg: string type annotation, the entire function is not contextually typed. #4241 removes the restriction that type annotations in functions "turn off" contextual typing. Should be an easy change if you want to take a stab at it.
TypeScript Version: 2.1.0-dev.20160910
Code
tsc -t es5 ./foo.ts
Expected behavior:
Both (1) and (2) should complain about
length
not existing onnumber
Actual behavior:
(1) correctly complains:
foo.ts(3,30): error TS2339: Property 'length' does not exist on type 'number'.
But there is no error for (2).Adding
--noImplicitAny
doesn't change the result.Adding
--noImplicitThis
givesfoo.ts(4,36): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
which confirms thatthis
in (2) is getting inferred asany
The text was updated successfully, but these errors were encountered: