我可以毫无问题地将模块解析器与 Javascript 一起使用。实际上,我可以在运行时毫无问题地将它与 Typescript 一起使用,但在开发部分我找不到Cannot find module or its corresponding type declerations问题的解决方案。我正在寻找答案我做错了哪一部分?
以下是文件:
.babelrc
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
[
"module-resolver",
{
"root": ["./src"],
"alias": [
{ "@shared-components": "./shared/components" },
{ "@shared-constants": "./shared/constants" },
{ "@shared-theme": "./shared/theme" },
{ "@font-size": "./shared/theme/font-size" },
{ "@api": "./services/api/index" },
{ "@fonts": "./shared/theme/fonts/index" },
{ "@colors": "./shared/theme/colors" },
{ "@theme": "./shared/theme/index" },
{ "@services": "./services" },
{ "@screens": "./screens" },
{ "@utils": "./utils/" },
{ "@assets": "./assets/" }
],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
]
]
}
tsconfig.json文件
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext"],
"allowJs": true,
"jsx": "react-native",
"noEmit": true,
"isolatedModules": true,
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
// ? Custom ones
"skipLibCheck": true,
"resolveJsonModule": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
// ? Babel Plugin Module Resolver
一只萌萌小番薯
相关分类