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
When migrating a large JS project to TS, one may find it infeasible to make the whole thing --noImplicitAny compliant at first, but still want to minimize the use of implicit anys in new code. I made my editor plugin always enable noImplicitAny errors unless explicitly disabled, but show them as warnings unless explicitly enabled. This worked great for a long time.
But in TS 2.1, there's a problem with this: --noImplicitAny now affects type checking due to the new control flow analysis. It can now add errors seemingly unrelated to implicit-any in some places, and remove them in others:
vara;a=0;a.foo;// ok without --noImplicitAny: a has type any// error with --noImplicitAny: a has type numberfunctionlast<T>(arr: T[]){returnarr[arr.length-1];}varb;b=["foo"];last(b).charAt(0);// error without --noImplicitAny: last(b) is inferred as type {}// ok with --noImplicitAny: last(b) is inferred as type string
This is a problem for the noImplicitAny-as-warnings feature in my editor, because the actual errors won't match up with command-line tsc or with other editors. I'll probably relegate it behind a nonstandard tsconfig.json option, with the understanding that it does have this problem.
But it would be nice if it could be a standard option instead. Not on by default, but suppose that noImplicitAny could be any of false, true, "warn". When set to "warn", tsc would enable the control flow type analysis but not report implicit-any errors, and editors would enable the analysis and report them only as warnings.
The text was updated successfully, but these errors were encountered:
When migrating a large JS project to TS, one may find it infeasible to make the whole thing --noImplicitAny compliant at first, but still want to minimize the use of implicit
any
s in new code. I made my editor plugin always enable noImplicitAny errors unless explicitly disabled, but show them as warnings unless explicitly enabled. This worked great for a long time.But in TS 2.1, there's a problem with this: --noImplicitAny now affects type checking due to the new control flow analysis. It can now add errors seemingly unrelated to implicit-any in some places, and remove them in others:
This is a problem for the noImplicitAny-as-warnings feature in my editor, because the actual errors won't match up with command-line
tsc
or with other editors. I'll probably relegate it behind a nonstandard tsconfig.json option, with the understanding that it does have this problem.But it would be nice if it could be a standard option instead. Not on by default, but suppose that
noImplicitAny
could be any offalse
,true
,"warn"
. When set to"warn"
,tsc
would enable the control flow type analysis but not report implicit-any errors, and editors would enable the analysis and report them only as warnings.The text was updated successfully, but these errors were encountered: