Suggestion: Disable runtime prop validation when using TypeScript for prop definitions #547
Replies: 1 comment
-
强烈支持, vue3为了支持typescript 定义props 把typescript定义 编译成运行时的es props校验 这个浪费了一年多的时间直到vue3.3才得到支持,而且至今一些复杂的类型还没有完全支持, 如果直接用纯ts校验 , ts定义成的props 直接编译成 |
Beta Was this translation helpful? Give feedback.
-
#549 is a suggestion to let runtime type validation be disabled with a config option. But to increase my chances of solving my use case, I'm making this alternate suggestion in addition to that: I want type validation to automatically be disabled on components with
defineProps
called with type parameters.I need this because otherwise Vue is sometimes unable to generate runtime validators, which is a pointless limitation when I don't even need runtime validators. Examples include vuejs/core#8468 and vuejs/core#8482. The impossibility of these prop types is needless since prop validators provide no significant benefit with TS anyway. And to be clear, yes, fixing those issues would solve that use case. But I think it would be good in general not to validate props at runtime when they're already being validated by TypeScript.
Furthermore, I don't think this would be a breaking change since prop validators are only compiled in development anyway, and this doesn't change any interface (that I'm aware of).
Beta Was this translation helpful? Give feedback.
All reactions