简体   繁体   English

“如果没有描述,‘@param’在 TypeScript 代码中是多余的。” TSLint 错误?

[英]"'@param' is redundant in TypeScript code if it has no description." TSLint error?

I have an Angular 8 project and I run ng lint .我有一个 Angular 8 项目,我运行ng lint

Even though I have a @description decorator associated with a particular method, TSLint complains and says: "'@param' is redundant in TypeScript code if it has no description."即使我有一个与特定方法相关联的@description装饰器,TSLint 也会抱怨并说: "'@param' is redundant in TypeScript code if it has no description." @param "'@param' is redundant in TypeScript code if it has no description." in various places in my code.在我的代码中的各个地方。

For example, the aforementioned error would show when a method is written like this (TypeScript):例如,上述错误会显示当一个方法是这样编写的(TypeScript):

  /**
   * @description my lovely description
   * @param empDetails
  */
  getHeaderBasedonEmpDetails(empDetails: EmployeeDetails) {
    if (someVar) {
      return 'yeah'
    } else {
      return 'nah'
    }
  }

package.json:包.json:

{
  "name": "example-app",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.0.0",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "^8.0.0",
    "@angular/compiler": "^8.0.0",
    "@angular/core": "^8.0.0",
    "@angular/flex-layout": "^8.0.0-beta.26",
    "@angular/forms": "^8.0.0",
    "@angular/http": "^7.2.15",
    "@angular/language-service": "^8.0.0",
    "@angular/material": "^6.3.3",
    "@angular/material-moment-adapter": "^6.4.6",
    "@angular/platform-browser": "^8.0.0",
    "@angular/platform-browser-dynamic": "^8.0.0",
    "@angular/router": "^8.0.0",
    "common-logger-angular": "^1.0.0",
    "hammerjs": "^2.0.8",
    "moment": "^2.24.0",
    "ng-click-outside": "^4.0.0",
    "ng2-pdf-viewer": "^5.2.1",
    "ngx-device-detector": "^1.3.5",
    "rxjs": "^6.5.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.1",
    "@angular-devkit/build-ng-packagr": "~0.800.1",
    "@angular/cli": "~8.0.1",
    "@angular/compiler-cli": "^8.0.0",
    "@compodoc/compodoc": "^1.1.8",
    "@types/jasmine": "~3.3.13",
    "@types/jasminewd2": "~2.0.6",
    "@types/karma-viewport": "^0.4.0",
    "@types/node": "~12.0.4",
    "codelyzer": "~5.1.0",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.4",
    "karma-ie-launcher": "^1.0.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "karma-junit-reporter": "^1.2.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-viewport": "^1.0.4",
    "karma-webdriver-launcher": "^1.0.5",
    "lighthouse": "^5.1.0",
    "ng-packagr": "^5.2.0",
    "promise-polyfill": "^8.1.0",
    "protractor": "~5.4.2",
    "rimraf": "^2.6.3",
    "ts-node": "~8.2.0",
    "tsickle": "^0.35.0",
    "tslib": "^1.7.1",
    "tslint": "~5.17.0",
    "typedoc": "^0.14.2",
    "typescript": "3.4.5"
  }
}

tsconfig.json: tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "module": "commonjs",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

tslint.json (relevant (in root)): tslint.json(相关(在根目录中)):

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "completed-docs": false,
    ...
  }
}

tslint.json (relevant (in /src)): tslint.json(相关(在/src 中)):

{
  "extends": "../tslint.json",
  "rules": {
    "completed-docs": false,
    ...
  }
}

I have tried:我试过了:

  • As shown in the tslint files, manually disabling the completed-docs rule.如 tslint 文件中所示,手动禁用completed-docs规则。
  • Adding /* tslint:disable:completed-docs */ to the top of the file where TSLint is complaining/* tslint:disable:completed-docs */到 TSLint 抱怨的文件顶部
  • Removing @description decorator and leaving it as just a comment删除@description装饰器并将其保留为评论

What exactly is going wrong?究竟出了什么问题?

You should add some small description behind empDetails您应该在empDetails后面添加一些小说明

  /**
   * @description my lovely description
   * @param empDetails contain employee details
  */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM