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

深藏阁楼爱情的钟 2023-06-07 08:11 87阅读 0赞

Angular报错:Type string trivially inferred from a string literal, remove type annotation

  1. stockCode: string = 'IBM';

tslint觉得根据’IBM’判断出stockCode的类型是string,所以再写成string类型是多此一举。

那么怎么去掉这条规则呢?

ctrl+shift+p搜索tslint,选择TSLint:Create a ‘tslint.json’ file

将:

  1. "no-inferrable-types": [
  2. true,
  3. "ignore-params"
  4. ],

改成:

  1. "no-inferrable-types": [
  2. true,
  3. "ignore-params",
  4. "ignore-properties"
  5. ],

发表评论

表情:
评论列表 (有 0 条评论,87人围观)

还没有评论,来说两句吧...

相关阅读