Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6291

ReactNative, typescript absolute path setting -> importing is working fine but warning comes up in vscode

$
0
0

I'm using typescript and setup absolute path usage through tsconfig.json and babel.config.js.It totally worked fine but suddenly vscode emits some error.Strangely, importing components works perfectly fine. I guess it's a problem from vscode but I don't know how to solve the problem.

Here is my tsconfig.json

{"extends": "@tsconfig/react-native/tsconfig.json","compilerOptions": {"allowSyntheticDefaultImports": true, // turn on allowSyntheticDefaultImports"baseUrl": ".","paths": {"@/*": ["./src/*"]        }    },"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]}

And this is my babel.config.js

module.exports = {    presets: ['module:metro-react-native-babel-preset'],    plugins: [        ['module-resolver',            {                root: ['./src'],                extensions: ['.ios.ts', '.android.ts', '.ts', '.ios.tsx', '.android.tsx', '.tsx', '.jsx', '.js'],                alias: {'@': './src',                },            },        ],'react-native-reanimated/plugin',    ],};

And these are one of the importing codes and an error.

import {ScaledSDText as Text} from '@/components/common/ScaledText';

Cannot find module '@/components/common/ScaledText' or its corresponding type declarations.

enter image description here

And auto complete for importing is not working anymore. What is the problem? :(please help me..

I don't know but maybe problem came from vscode settings.


Viewing all articles
Browse latest Browse all 6291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>