We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b6d9ec4 commit ff21cd7Copy full SHA for ff21cd7
doc/handbook/Module Resolution.md
@@ -215,12 +215,16 @@ TypeScript编译器通过使用`tsconfig.json`文件里的`"paths"`来支持这
215
"compilerOptions": {
216
"baseUrl": ".", // This must be specified if "paths" is.
217
"paths": {
218
- "jquery": ["node_modules/jquery/dist/jquery"]
+ "jquery": ["node_modules/jquery/dist/jquery"] // 此处映射是相对于"baseUrl"
219
}
220
221
222
```
223
224
+请注意`"paths"`是相对于`"baseUrl"`进行解析。
225
+如果`"baseUrl"`被设置成了除`"."`外的其它值,比如`tsconfig.json`所在的目录,那么映射必须要做相应的改变。
226
+如果你在上例中设置了`"baseUrl": "./src"`,那么jquery应该映射到`"../node_modules/jquery/dist/jquery"`。
227
+
228
通过`"paths"`我们还可以指定复杂的映射,包括指定多个回退位置。
229
假设在一个工程配置里,有一些模块位于一处,而其它的则在另个的位置。
230
构建过程会将它们集中至一处。
0 commit comments