Javascript 将tsconfig路径与角度库一起使用?

Javascript 将tsconfig路径与角度库一起使用?,javascript,angular,typescript,Javascript,Angular,Typescript,我正在创建一个角度库,并在tsconfig.lib.json中添加了以下路径配置: "compilerOptions": { "outDir": "../../out-tsc/lib", "target": "es2015", "declaration": true, "inlineSources": true, "types": [], "lib": [ "dom", "es2018" ], "path

我正在创建一个角度库,并在
tsconfig.lib.json
中添加了以下
路径
配置:

  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ],
    "paths": {
      "@fs/*": ["src/lib/*"]
    }        
  }
但是,尝试导入以下内容:

import { Test } from '@fs/Test'

不起作用。有人知道Angular库是否支持
tsconfig.lib.json
中的hte
路径
配置选项吗


通常我使用
typescript转换路径
对编译后的结果执行路径转换,我希望Angular在库中烘焙了类似的东西?

尝试在tsconfig.json文件中使用以下模式:

"paths": {
  "@services/*": ["app/path/to/services/*"],
  "@components/*": ["app/path/to/some/deeply/nested/component/*"],
  "@environments/*": ["environments/*"] 
},
然后在导入时:

import { yourServiceClass } from "@services/yourServiceClass";

这很难实现,但有时您必须重新打开vscode并重新启动服务器才能识别新路径。如果您还没有这样做,请尝试。在这种情况下,它无法在工具中识别它。它可以识别正常的Angular应用程序项目,但在库项目中不起作用。谢谢!这很有效-我必须将其添加到顶级
tsconfig.json
文件中。这是我的Jest配置,以防有人尝试执行类似操作: