【发布时间】:2023-04-10 14:56:01
【问题描述】:
我有一个 Angular 项目,其中包含 RxJs 库操作符之类的东西,
map,do 等不被导入。源中似乎没有通配符导入。
我的 Ionic 和 Angular 项目都可以:
import { Observable } from 'rxjs';
然后我有一个 Ionic 项目,如果我没有明确说明导入,它会抱怨。
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
此外,在 Ionic 项目中,我似乎也无法在 RxJS 的 node_modules 文件夹中找到 refCount。虽然现在,我开始认为我需要一个像 rx.lite.js 这样的特定包......我不知道 rx.lite.js 和 rx.lite-aggregates.js 是如何添加到 Angular 项目中的在 node_modules 文件夹中。我在我的 Ionic 项目中没有做到这一点。 Angular 项目的 package.json 中没有明确引用它们。也许是某种传递依赖?
Angular 项目是我从 Git 存储库中获得的,所以我想知道是否有某种配置文件可以在项目的其他地方执行此操作。 我想知道是否有人可以帮助我解开这个谜团。
-
Angular 项目 package.json rxjs 依赖
"rxjs": "^5.1.0", -
Angular 项目 tsconfig.json
{ "compileOnSave": false, "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es2016" ], "module": "commonjs", "moduleResolution": "node", "outDir": "../dist/out-tsc-e2e", "sourceMap": true, "target": "es6", "typeRoots": [ "../node_modules/@types" ] } } -
Ionic 项目 package.json rxjs 依赖
"rxjs": "5.1.1", -
离子项目 tsconfig.json
{ "compilerOptions": { "allowSyntheticDefaultImports": true, "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "dom", "es2015" ], "module": "es2015", "moduleResolution": "node", "sourceMap": true, "target": "es5" }, "include": [ "src/**/*.ts" ], "exclude": [ "node_modules" ], "compileOnSave": false, "atom": { "rewriteTsconfig": false }}
我一直在尝试理解 tsconfig.json。看到这个link
【问题讨论】:
-
我阅读了这些帖子,但它们并没有真正为我澄清事情。
-
我现在怀疑 tslint.json 实际上负责黑名单。我在以 ng new 开始的项目中看到了以下形式的语法:“rules:” {“import-blacklist”: [true, “rxjs”]}。
标签: typescript import rxjs