我正在使用 Nx 工具将我的 Angular 11 应用程序重构为库。我的主要应用程序具有@angular/localize
依赖项并@angular/localize
导入polyfills.ts
. $localize
我的库代码中的每次使用都会产生 Typescript 错误TS2304: Cannot find name '$localize'
。我的图书馆没有自己的package.json
文件。应用程序构建工作没有错误。它看起来像打字稿打字问题。有任何想法吗?
库 tsconfig.lib.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
],
"include": [
"**/*.ts"
]
}
库中的 tsconfig.json
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
角版
Angular CLI: 11.1.1
Node: 14.15.4
OS: win32 x64
Angular: 11.1.0
... animations, cdk, common, compiler, compiler-cli, core
... elements, forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: <error>
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1002.1
@angular-devkit/build-angular 0.1101.1
@angular-devkit/core 10.2.1
@angular-devkit/schematics 11.0.7
@angular/cli 11.1.1
@schematics/angular 11.0.7
@schematics/update 0.1101.1
rxjs 6.6.3
typescript 4.1.3