--noImplicitThis error is inconsistent
See original GitHub issueTypeScript Version: 3.0.0-dev.20180707
Code
declare function f(a: any): void;
f(function() {
this.m();
});
f({
callback: function() {
this.m();
}
});
Expected behavior:
With --noImplicitThis
, errors in both cases or neither case.
Actual behavior:
Only error in the first case.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Inconsistent implicitly has an 'any' type error - Stack Overflow
I'm using TypeScript Version 2.3.2. I experienced a transpile error with noImplicitAny option. I feel that the erro is something inconsistent.
Read more >TSConfig Reference - Docs on every TSConfig option
No Implicit This - noImplicitThis. Raise error on 'this' expressions with an implied 'any' type. For example, the class below returns a function...
Read more >TypeScript Tutorial => Configuration for fewer programming ...
Learn TypeScript - Configuration for fewer programming errors. ... Disallow inconsistently-cased references to the same file.
Read more >How To Configure tsconfig.json: TypeScript Strict options
You need to set some type to avoid this TypeScript error. ... TypeScript Strict options in tsconfig.json: noImplicitThis.
Read more >Understanding TypeScript Configuration Options
Types of parameters 'age' and 'age' are incompatible. ... When noImplicitThis is enabled, TypeScript will raise an error when this ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That situation seems even worse because you never declared an
any
anywhere. But it would be likely to be fixed when this one is, so I’ll make it a part of this issue.A workaround is to declare an explicit type for
c
, as inconst c: Array<{ xxx(): void }> = [];
.Array.push
should have a parameter of typeT
whereT
is the array’s element type. With--noImplicitAny
enabled, if the array didn’t have a declared type we should be inferring one – not just making itany
.