microsoft / TypeScript-React-Native-Starter

A starter template for TypeScript and React Native with a detailed README describing how to use the two together.
MIT License
1.91k stars 211 forks source link

@types/node/index.d.ts(138,13): error TS2300: Duplicate identifier 'require' #19

Open ekapasha17 opened 6 years ago

ekapasha17 commented 6 years ago

I got several error when I following this guide and there's error about jsx : error TS2604: JSX element type 'Index' does not have any construct or call signatures image image

changtimwu commented 6 years ago

This workground works for me. https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15960#issuecomment-346645559

ekapasha17 commented 6 years ago

@changtimwu solved,I added "types": ["react", "react-native", "jest"] to my tsconfig but I still dont understand,what it does,maybe you can explain it ("types": ["react", "react-native", "jest"])

vladinator1000 commented 6 years ago

Adding "types" to tsconfig.json didn't work for me

Edit: because I didn't know you're supposed to add them under "compilerOptions"...

{
  "compilerOptions": {
    "types": ["react", "react-native", "jest"],
    // ...
  }
} 
stewhi commented 6 years ago

@savovs, Nice catch, that helped me a lot.

Unfortunately, when the compiler skips node, I still get errors, my project has dependencies on both node and react-native. Has there been any progress on this? Or are node and react-native mutually exclusive?

StevenTCramer commented 6 years ago

I am having same issue: as @stewhi added stackoverflow question.

https://stackoverflow.com/questions/49495257/adding-styled-components-to-project-causes-cannot-find-namespace-nodejs

lVlario0O0o commented 5 years ago

When I remove the node types it gives me a lot of errors...

nathguen commented 5 years ago

Adding "types" to tsconfig.json didn't work for me

Edit: because I didn't know you're supposed to add them under "compilerOptions"...

{
  "compilerOptions": {
    "types": ["react", "react-native", "jest"],
    // ...
  }
} 

For me, all I needed was:

{
  "compilerOptions": {
    "types": ["react"],
    // ...
  }
} 

... but this was a life saver!