swiper + ts 类型报错
swiper + ts 类型报错
"swiper": "^9.4.1" 版本号
修改 tsconfig.json 文件下面的 moduleResolution 为node
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
},
"target": "ES2020",
"useDefineForClassFields": true,
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode 类型报错在这里*/
"moduleResolution": "node",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"typeRoots": [
"./typings",
"./node_modules/@types"
]
},
"include": [
"src",
"typings/**/*.ts"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}