Rob*_*ste 5 rxjs visual-studio-code
我有一个项目,其中 VS Code 在使用 rxjs 运算符时不会建议导入。
myObservable.pipe(
take(1),
filter(result => result),
switchMap((result) => myOtherObserbable),
finalize(() => this.isLoading = false)
)
Run Code Online (Sandbox Code Playgroud)
在这种情况下,take、filter、switchMap和finalize不会在上下文菜单中提供任何建议:
我必须手动编写:
import { take, filter, switchMap, finalize } from "rxjs/operators";
然后就可以了。
什么可能导致这种情况以及我应该在哪里寻找?
在文件中找到了问题tsconfig:
"paths": {
"@app/*": ["app/*"],
"@env/*": ["environments/*"],
"@angular/*": ["../node_modules/@angular/*"],
"rxjs/*": ["../node_modules/rxjs/*"], // => Commenting this makes the imports work
"@custom/library": ["../../../path/to/custom/library/src"]
}
Run Code Online (Sandbox Code Playgroud)
我正在使用自定义库,并且必须为项目添加路径才能知道在哪里查找,但显然它破坏了自动导入
| 归档时间: |
|
| 查看次数: |
492 次 |
| 最近记录: |