解决 typescript import 路径太长的问题

需要在 tsconfig.json 文件中配置两处

"baseUrl": "./",
/* Base directory to resolve non-absolute module names. */
"paths": {
    "fridacontainer/*": [
        "./node_modules/@dmemory/fridacontainer/dist/*"
    ]
},
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
  • 如何生成 tsconfig.json
    > $ tsc –init

然后在 ts 中就可用短链接导入了

import {FCAnd} from "fridacontainer/FCAnd"

发表评论