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
// No errorconstf1=(debug=true)=>false;// Error, but shouldn't be -- contextual type from 'Function'// shouldn't have negative effects hereconstf2: Function=(debug=true)=>false;
This is actually working as intended. For f1 it is meaningful to infer from the initializer because the inferred type will constrain arguments that can be passed for debug. But for f2 we've already established that the type is Function. Thus, anything we infer for debug will be disregarded, and we have no idea what type of arguments will actually be passed (and keep in mind that the default value only kicks in when we're passed an undefined).
Having a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an
any
typeTypeScript Version:
3.7.4 (also reproduced on Nightly)
I recently upgraded from Typescript 3.5.2 to 3.7.3. The code below was fine with ts 3.5.2
Search Terms:
default parameter noImplicitAny
Code
Expected behavior:
No Errors
Actual behavior:
I get an error for the
debug = true
statement. "TS7006: Parameter 'debug' implicitly has an 'any' type."Playground Link:
Playground link
Related Issues:
None
The text was updated successfully, but these errors were encountered: