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
Expected behavior:
Compiled w/o error under 2.1 Actual behavior:
Generates error:
index.ts(9,4): error TS2322: Type 'RuleContext | undefined' is not assignable to type 'RuleContext'.
Type 'undefined' is not assignable to type 'RuleContext'.
We changed the type of defaulted parameters from T | undefined to T in 2.2, but it seems wrong to strip out undefined from an explicitly-written type annotation
This is an intended result of #12033, but we should revisit whether to use the control-flow-narrowing mechanism instead of the one that shipped, which simply strips off | undefined from default-initialised and optional parameters.
Activity
BurtHarris commentedon Mar 6, 2017
Simple workarounds possible, just surprised at the change in behavior.
Another repro case:
RyanCavanaugh commentedon Mar 6, 2017
We changed the type of defaulted parameters from
T | undefinedtoTin 2.2, but it seems wrong to strip outundefinedfrom an explicitly-written type annotationsandersn commentedon Mar 6, 2017
This is an intended result of #12033, but we should revisit whether to use the control-flow-narrowing mechanism instead of the one that shipped, which simply strips off
| undefinedfrom default-initialised and optional parameters.