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 typings not found in 3rd party package with peerDependency #1771

Closed
ondratra opened this issue Jul 12, 2019 · 6 comments
Closed

React typings not found in 3rd party package with peerDependency #1771

ondratra opened this issue Jul 12, 2019 · 6 comments

Comments

@ondratra
Copy link

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?

@JoviDeCroock
Copy link
Member

Hey what version of preact are you using?

@ondratra
Copy link
Author

Preact 10.0.0-rc.0

@JoviDeCroock
Copy link
Member

Then you shouldn't use preact-compat but preact/compat

@ForsakenHarmony
Copy link
Member

Also think you might have to install @types/react

@ondratra
Copy link
Author

Sorry for confusion I made: I tried both current stable preact version with preact-compat and preact X with preact/compat as documentation suggested. Plus i don't think you can include both preact and @types/react to the same project. I tried that for 8.x.x version and it conflicts (known issue) - I haven't tried that with Preact X.

After some more digging into the problem I found that when running

browserify src/index.tsx  -t [aliasify] --global-transform=aliasify -p [tsify -p tsconfig.json] -o dist/bundle.js

command aliasify transform get's ignored. As stated here tsify plugin can't use other tranforms.

tsify also doesn't support Typescript's path directive, while browserify doesn't support ES6 imports in it's b.require('x', {expose: 'y'}); another dead end.

Is there anybody that got components originally created for react working in stack Typescript + Browserify + Preact? At this point I think this is more like tsify's issue than preact's, but I would be glad if anybody can give me hint.

@ondratra
Copy link
Author

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

Thanks everyone for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants