Jae*_*ang 3 node-modules typescript tsc reactjs react-admin
我使用反应管理和打字稿。
我更喜欢使用strict
类型检查。所以当我运行时tsc
,react admin 向我显示一个implicitly any
错误。
虽然我用了"skipLibCheck": true
,但是还是报错了。我该如何修复它?
node_modules/ra-core/src/auth/useCheckAuth.ts:101:26 - error TS7006: Parameter 'error' implicitly has an 'any' type.
101 const getErrorMessage = (error, defaultMessage) =>
~~~~~
Run Code Online (Sandbox Code Playgroud)
下面是我的 tsconfig 文件。
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"paths": {
"@components/*": ["components/*"],
"@styles/*": ["styles/*"],
"@lib/*": ["lib/*"],
"@pages/*": ["pages/*"]
}
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
Run Code Online (Sandbox Code Playgroud)
我在我的代码库中发现了一个问题,这就是邪恶的根源。
import {
CreateResult,
DeleteResult,
GetListResult,
GetManyReferenceResult,
GetManyResult,
GetOneResult,
UpdateResult,
} from 'ra-core/src/types';
Run Code Online (Sandbox Code Playgroud)
如果我像上面一样从 'ra-core/src/types' 导入 pkgs,它会抛出 ts 错误。
您可以通过从“ra-core”导入包来修复它,如下所示。
import {
CreateResult,
DeleteResult,
GetListResult,
GetManyReferenceResult,
GetManyResult,
GetOneResult,
UpdateResult,
} from 'ra-core';
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
405 次 |
最近记录: |