我正在尝试做一些非常类似于文档中的jquery路径示例的东西,但TS不断抛出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?
],
Run Code Online (Sandbox Code Playgroud)
更改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
Run Code Online (Sandbox Code Playgroud)