[vue-ts]ts版本问题合集

[vue插件]ts版本问题合集

在使用ts进行代码开发的化,首先要注意以下几点:

使用的包添加ts支持

例如mockjs添加 @types/mockjs支持(如果存在)

或者在shims-vue.d.ts添加声明

类型检查报错

Parameter ‘b’ implicitly has an ‘any’ type

在.eslinttrc.js文件中添加配置很多都无效

Argument ‘callback’ should be typed (@typescript-eslint/explicit-module-boundary-types) at

tsconfig.json中"strict": false,

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

使用了require方法

warning: Missing return type on function

添加返回或者设置为void

warning: Unexpected any. Specify a different type (@typescript-eslint/no-explicit-any)

“@typescript-eslint/no-explicit-any”:“off”

error: ‘text’ is defined but never used (vue/no-unused-vars)

‘@typescript-eslint/no-unused-vars’: “off”,
‘vue/no-unused-vars’: “off”,
‘no-unused-vars’: “off”,
都无效

‘v-show’ directives cannot be put on tags

v-show调整到具体的dom上

Don’t use object as a type. The object type is currently hard to use

类型暂时改为any

error: The array literal notation [] is preferable (@typescript-eslint/no-array-constructor)

error: Don’t use Function as a type. The Function type accepts any function-like value. It provides no type safety when calling the function, which can be a common source of bugs. It also accepts things like class declarations, which will throw at runtime as they will not be called with new. If you are expecting the function to accept certain arguments, you should explicitly define the function shape (@typescript-eslint/ban-types)

error: Type RegExp trivially inferred from a RegExp literal, remove type annotation

error: Irregular whitespace not allowed

“no-irregular-whitespace”: “off”,

它就是由不规则空格引起的,解决办法就是要格式化文档。

You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.

chainWebpack(config) {
        config.resolve.alias.set(‘vue-i18n’,‘vue-i18n/dist/vue-i18n.cjs.js’)
}

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

vue.config.js 设置
client:{
            overlay:false
 },

TS2698: Spread types may only be created from object types

Object.assign(target,source)

TS2769: No overload matches this call.

export declare function createI18n
<Legacy extends boolean = true, 
Options extends I18nOptions = I18nOptions,
Messages = Options[‘messages’] extends object ? Options[‘messages’] : {}, 
DateTimeFormats = Options[‘datetimeFormats’] extends object ? Options[‘datetimeFormats’] : {}, 
NumberFormats = Options[‘numberFormats’] extends object ? Options[‘numberFormats’] : {}, 
OptionLocale = Options[‘locale’] extends string ? Options[‘locale’] : Locale>
(options: Options, LegacyVueI18n?: any): I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, Legacy>;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三知之灵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值