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
{{ message }}
Repository navigation
Union type method parameters in base class accepts incompatible types in subclass overrides #19832
Using union types in base class method declarations allows override functions that only declare one of the union member types. This produces code that crashes at runtime, even with --strict.
Aha, I had missed the part where --strictFunctionTypes does not apply to methods. I take it I should stay away from inheritance if I want contravariant parameter checking then.
Activity
ahejlsberg commentedon Nov 8, 2017
See here for an explanation:
https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant
Also, see #18654.
asmundg commentedon Nov 8, 2017
Aha, I had missed the part where
--strictFunctionTypesdoes not apply to methods. I take it I should stay away from inheritance if I want contravariant parameter checking then.