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
This happens when you use global directives, inside a script setup component, then compile with TS typechecking (and --strictNullChecks).
What is expected?
Everything compiles fine!
What is actually happening?
semantic error TS2322: Type 'Directive<any, any> | undefined' is not assignable to type 'Directive<any, any>'.
Type 'undefined' is not assignable to type 'Directive<any, any>'.
Basically _resolveDirective is typed as possibly undefined (understandable if the name isn't registered) but _withDirectives is typed as accepting Directive only, not undefined.
Fix ideas:
Ensure _withDirectives works with (ignores?) undefined directives.
Make _resolveDirective throw when the directive is not found and returns Directive<any, any>
Don't change any behavior but lie in type definitions to pretend _resolveDirective never returns undefined or _withDirectives accepts undefined.
The text was updated successfully, but these errors were encountered:
Version
3.1.3
Reproduction link
https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8aDE e3sgbXNnIH19PC9oMT5cbiAgPGlucHV0IHYtYXV0b2ZvY3VzIC8 XG48L3RlbXBsYXRlPlxuXG48c2NyaXB0IHNldHVwPlxuY29uc3QgbXNnID0gJ0hlbGxvIFdvcmxkISdcbjwvc2NyaXB0PiJ9
Steps to reproduce
This happens when you use global directives, inside a script setup component, then compile with TS typechecking (and --strictNullChecks).
What is expected?
Everything compiles fine!
What is actually happening?
I believe I know what the problem is.
The generated code looks like this:
Basically
_resolveDirective
is typed as possiblyundefined
(understandable if the name isn't registered) but_withDirectives
is typed as acceptingDirective
only, notundefined
.Fix ideas:
_withDirectives
works with (ignores?)undefined
directives._resolveDirective
throw when the directive is not found and returnsDirective<any, any>
_resolveDirective
never returns undefined or_withDirectives
accepts undefined.The text was updated successfully, but these errors were encountered: