我试图做与文档中jquery路径示例非常相似的事情,但TypeScript一直报错TS2307
(webpack编译正常):
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@client": [
"client",
],
"@suir": [
"../node_modules/semantic-ui-react/dist/commonjs", // not working
],
},
// …
},
"include": [
"*.d.ts",
"client/**/*",
"../node_modules/semantic-ui-react", // is this necessary?
],
改变 baseUrl
为 "."
并更新 includes
和 paths
不会有任何影响(@client
继续工作,@suir
仍然无法工作)。将
"@suir"
改为 "@suir/"
或 "@suir/*"
(并在其值后添加 /*
)也没有任何影响。
我这么做的原因是为了简化我的导入(我正在明确指定它们,而不是从包中拉出命名的导出,以减少我的供应商捆绑包大小 - 节省约1 MB)。
import Button from 'semantic-ui-react/dist/commonjs/elements/Button'; // works
import Button from '@suir/elements/Button'; // not found
files
属性时,paths
就不起作用了。有什么解决办法吗? - Yashas