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

Make typescript compile/lint from the other modules/packages in monorepo

$
0
0

I am new to using monorepo with Typescript which has a react-native project and a common folder which contains the common files to be shared across projects and it is configured and works fine when the app is running.

I am facing problem with Typescript which shows error in the common files import statements where react-native components are imported and used. It says Cannot find module 'react-native' or its corresponding type declarations.ts(2307). So is there a way to make Typescript to look for the import into the react-native project (Mobile directory) node_modules?

Monorepo structure:

monorepo    |    |---Common    |    |---Mobile 

Common's tsconfig.json

{"compilerOptions": {"allowJs": true,"allowSyntheticDefaultImports": true,"esModuleInterop": true,"isolatedModules": true,"jsx": "react-native","lib": ["es2021"    ],"moduleResolution": "node","noEmit": false,"strict": true,"target": "esnext","rootDir": "./","outDir": "./dist","composite": true,"declaration": true,"declarationMap": true,"baseUrl": ".",},}

Mobile's tsconfig.json

{"compilerOptions": {"allowJs": true,"allowSyntheticDefaultImports": true,"esModuleInterop": true,"isolatedModules": true,"jsx": "react-native","lib": ["es2021"    ],"moduleResolution": "node","noEmit": false,"strict": true,"target": "esnext","baseUrl": ".","paths": {"*": ["*", "../Common/*"]    },"composite": true,"rootDir": "./","outDir": "./dist","declaration": true,"declarationMap": true,},"references": [{ "path": "../Common" }],"exclude": ["node_modules","babel.config.js","metro.config.js","jest.config.js"]}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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