Appearance
vue/require-typed-ref
要求
ref
和shallowRef
函数为强类型¥require
ref
andshallowRef
functions to be strongly typed
📖 规则详情
此规则禁止在使用 TypeScript 时调用没有泛型类型参数或参数的 ref()
或 shallowRef()
函数。
¥This rule disallows calling ref()
or shallowRef()
functions without generic type parameter or an argument when using TypeScript.
使用 TypeScript,可以通过使用 noImplicitAny
轻松防止使用 any
。不幸的是,此规则很容易通过 Vue ref()
函数绕过。在没有泛型参数或初始值的情况下调用 ref()
函数会导致 ref 具有 Ref<any>
类型。
¥With TypeScript it is easy to prevent usage of any
by using noImplicitAny
. Unfortunately this rule is easily bypassed with Vue ref()
function. Calling ref()
function without a generic parameter or an initial value leads to ref having Ref<any>
type.
🔧选项
¥🔧 Options
无。
¥Nothing.
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v9.15.0 中引入
¥This rule was introduced in eslint-plugin-vue v9.15.0
🔍代码实现
¥🔍 Implementation