警告:条件始终为假

时间:2019-09-03 10:04:00

标签: angular

我使用Angular库。 我有主要的tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "allowUnreachableCode":true,
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "core": [
        "dist/core"
      ],
      "core/*": [
        "dist/core/*"
      ],
      "@angular/*": [
        "node_modules/@angular/*"
      ],
      "rxjs": [
        "node_modules/rxjs"
      ],
      "rxjs/*": [
        "node_modules/rxjs/*"
      ]
    }
  }
}

和tsconfig.json用于我的库

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [
      "jasmine"
    ],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true,
    "warnings": false,
  },
  "exclude": [
    "dist",
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

当我构建Angular库时,会收到很多警告。例如: WARNING: Condition always false 我用 ng build --project my-lib 我有许多类似的界面,例如:

export interface IPagination {
  prevUrl?: string;
  selfUrl?: string;
  nextUrl?: string;
  number: number;
  size: number;
  totalElements: number;
  totalPages: number;
}

为此接口生成以下代码

 function IPagination() { }
    if (false) {
        /** @type {?|undefined} */
        IPagination.prototype.prevUrl;
        /** @type {?|undefined} */
        IPagination.prototype.selfUrl;
        /** @type {?|undefined} */
        IPagination.prototype.nextUrl;
        /** @type {?} */
        IPagination.prototype.number;
        /** @type {?} */
        IPagination.prototype.size;
        /** @type {?} */
        IPagination.prototype.totalElements;
        /** @type {?} */
        IPagination.prototype.totalPages;
    }

我收到每个此类界面的警告。 为什么会变成不可能的情况? 如何禁用此警告或解决此问题?

I also get such warnings:
WARNING: Dropping unreachable code [0:178,8]
WARNING: Dropping side-effect-free statement [0:55,8]
WARNING: Dropping unused function __exportStar [0:113,13]
WARNING: Dropping unused function __spread [0:145,13]
WARNING: Dropping unused function __spreadArrays [0:151,13]
WARNING: Dropping unused function __asyncGenerator [0:163,13]
WARNING: Dropping unused function __asyncDelegator [0:175,13]
WARNING: Dropping unused function __asyncValues [0:181,13]
WARNING: Dropping unused function __makeTemplateObject [0:189,13]
WARNING: Dropping unused function __importStar [0:194,13]
WARNING: Dropping unused function __importDefault [0:202,13]

如何解决这些警告?

0 个答案:

没有答案