我在 Webstorm 中使用 i18next 进行反应时遇到问题。一切正常,但在我初始化 i18n 的 i18n.ts 中,我的这段代码用红色下划线和这个错误。
另外,我对 useTranslation 中的 t() 函数也有类似的问题。
我的依赖项和 devDependency
"devDependencies": {
"@svgr/webpack": "^8.1.0",
"@types/copy-webpack-plugin": "^10.1.0",
"@types/node": "^20.11.16",
"@types/react": "^18.2.53",
"@types/react-dom": "^18.2.18",
"@types/react-router-dom": "^5.3.3",
"@types/webpack": "^5.28.5",
"@types/webpack-dev-server": "^4.7.2",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"css-loader": "^6.10.0",
"eslint": "^8.56.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-config-xo": "^0.44.0",
"eslint-config-xo-typescript": "^2.0.0",
"eslint-plugin-i18next": "^6.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-unused-imports": "^3.0.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.8.0",
"sass": "^1.70.0",
"sass-loader": "^14.1.0",
"style-loader": "^3.3.4",
"stylelint": "^16.2.1",
"stylelint-config-standard-scss": "^13.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"webpack": "^5.90.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"i18next": "^23.8.2",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.4",
"react-router-dom": "^6.22.0"
}
tsconfing 文件
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "ESNext",
"target": "es5",
"jsx": "react-jsx",
"allowJs": true,
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": [ "./src/*" ]
},
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": [
"ESNext",
"dom",
]
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
}
Удалось решить данную проблему?