Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(react-native) Typescript error: Cannot find name 'Buffer'/'http'/'https' #1926

Closed
dudunato opened this issue Feb 12, 2018 · 5 comments
Closed
Labels
third-party This issue is related to third-party libraries or applications. typings Issue is related to typings.

Comments

@dudunato
Copy link

Hey there,

After following the steps of #1271 and adding the types to my tsconfig.json then it gives me another error:

node_modules/@types/react-native/index.d.ts(8630,14): error TS2300: Duplicate identifier 'require'.
node_modules/@types/node/index.d.ts(140,13): error TS2300: Duplicate identifier 'require'.

Here's my tsconfig.json:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "jsx": "react",
    "outDir": "compiled",
    "rootDir": "./src",
    "types": ["node", "react", "react-native", "jest"]
  },
  "include": ["./src/**/*"],
  "exclude": [
    "./compiled",
    "./node_modules"
  ]
}

It seems that node types are conflicting with react-native. Any thoughts?

@jeskew jeskew added Third Party typings Issue is related to typings. labels Feb 13, 2018
@jeskew
Copy link
Contributor

jeskew commented Feb 13, 2018

It looks like there is an open PR that might address this issue on the DefinitelyTyped repository. Unfortunately, there's nothing we can do in the SDK about this while the issue is being resolved by the maintainers of the @types/node and @types/react-native packages.

As a workaround, you could add bespoke typings for the portions of the React Native API that are called directly by the application being compiled (per the advice given in DefinitelyTyped/DefinitelyTyped#15960).

@kevinsperrine
Copy link

@dudunato I just hacked around it. aws-amplify/amplify-js#281 (comment) ¯_(ツ)_/¯

@dudunato
Copy link
Author

dudunato commented Mar 8, 2018

I just ignored it on my tsconfig (but not a good solution at all). I might migrate to yours! Thanks so much for sharing, @kevinsperrine!

@srchase
Copy link
Contributor

srchase commented Nov 29, 2018

As this is still being sorted out in DefinitelyTyped, I'm going to close this isssue.

@srchase srchase closed this as completed Nov 29, 2018
@srchase srchase added third-party This issue is related to third-party libraries or applications. and removed third-party labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
third-party This issue is related to third-party libraries or applications. typings Issue is related to typings.
Projects
None yet
Development

No branches or pull requests

4 participants