首页 > 其他 > 详细

Type string trivially inferred from a string literal, remove type annotation

时间:2021-08-25 18:13:44      阅读:17      评论:0      收藏:0      [点我收藏+]

在这里可以明显的看到这句话的意思就是:简单地从字符串字面量推断类型字符串,删除类型注释
意思就是已经知道你所赋值后这个元素的类型已经被检测出来了

public name:string = "www"

那么这个时候就要检测你的项目中检测是tsLine还是esLine

tsLine的解决方法就是把

    "no-inferrable-types": [
      true,
      "ignore-params"
    ],

改成

    "no-inferrable-types": [
      true,
      "ignore-params",
      "ignore-properties"
    ],

如果是esLine在文件中

rules: {
    ‘no-console‘: process.env.NODE_ENV === ‘production‘ ? ‘warn‘ : ‘off‘,
    ‘no-debugger‘: process.env.NODE_ENV === ‘production‘ ? ‘warn‘ : ‘off‘,
    // 去除ts类型检测
    "@typescript-eslint/no-inferrable-types": "off" 
  },

本文连接:点击
博主个人小博客:嘿嘿

Type string trivially inferred from a string literal, remove type annotation

原文:https://www.cnblogs.com/wwj0418/p/15184956.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!