禁用 ng-packagr 中的 TypeScript 不匹配

Sam*_*ann 0 angular-cli ng-packagr

在 Angular CLI 项目中,当使用不受支持的 TypeScript 版本时,您可能会收到以下警告:

@angular/compiler-cli@6.1.0 requires typescript@'>=X.X.X <Y.Y.Y' but Z.Z.Z was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.
Run Code Online (Sandbox Code Playgroud)

可以使用以下命令禁用默认项目的 TypeScript 不匹配警告:

ng config cli.warnings.typescriptMismatch false
Run Code Online (Sandbox Code Playgroud)

现在,在构建 Angular 库时,即使将设置设置为ng-packagr,也会将此警告作为错误抛出。是否可以暂时禁用此错误?据了解,这不应该在生产环境中完成,但在调试可能由 TypeScript 引起的问题时可能会有所帮助。以下StackOverflow 问题作为示例用例。typescriptMismatchfalse

A. *_*ius 7

您需要在 tsconfig 中disableTypeScriptVersionCheck使用。angularCompilerOptions