且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在打字稿中导入模块时,绝对路径的根源是什么?

更新时间:2022-06-18 22:55:30

很遗憾,我在文档中找不到任何内容.因此,在尝试解析绝对路径的导入时,我跟踪了由编译器(TypeScript 2.5.2)执行的文件系统访问.

Unfortunately I couldn't find anything on that in the docs. So I traced the file system accesses performed by the compiler (TypeScript 2.5.2) when trying to resolve an import of an absolute path.

结果是 /始终引用文件系统根目录.不管compilerOptions(例如rootDirrootDirsbaseUrl).

The result is that / always refers to the file system root. Regardless of compilerOptions like rootDir, rootDirs or baseUrl.