Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React typings not found in 3rd party package with peerDependency

See original GitHub issue

Hello, I am trying to get working library react-sortable-hoc with preact and browserify in Typescript.
I tried to alias the react package with aliasify as described in preact-compat package’s readme. Unfortunately react-sortable-hoc has peerDependency on react and even when aliasing for .ts files works fine I’ve encountered an error in typescript definition of the package (in .d.ts file) :

TypeScript error: node_modules/react-sortable-hoc/types/index.d.ts(1,24): Error TS2307: Cannot find module 'react'.

I’ve been trying different approaches to solve this but none of them were successfull. So I would like to know if there is anything I can do to get that working? Also could preact-compat somehow provide react typings that would solve the problems with preact + peer dependency in 3rd party react packages?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

ForsakenHarmonycommented, Jul 12, 2019

Also think you might have to install @types/react

ondratracommented, Jul 18, 2019

Alias can be done via pathmodify plugin for browserify see how to do that in this ticket.

Thanks everyone for help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to publish a JS package that gracefully fails if an optional ...
In order for the new context provider to use the right react-dnd instance, I had to make it a peerDependencies entry and not...
Read more >
Understanding Peer Dependencies in JavaScript
In this case, you would declare React as a peer dependency for your ... Notice how the package has no direct dependency, even...
Read more >
ts-node - npm
TypeScript icon, indicating that this package has built-in type declarations ... Missing Types; npx, yarn dlx, and node_modules. Performance.
Read more >
package.json | pnpm
If all projects in the monorepo use the same version of react , then no ... of the current package in the specified...
Read more >
Build a component library with React and TypeScript
Resolving third-party dependencies in node_modules; Transpiling our TypeScript code to JavaScript; Preventing bundling of peerDependencies ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found