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

Can't use tfjs-vis in a React app due to Preact typings collision #1415

Closed
davidsoergel opened this issue Mar 19, 2019 · 3 comments
Closed
Assignees
Labels
comp:vis type:support user support questions

Comments

@davidsoergel
Copy link
Member

Depending on tfjs-vis from our React app causes trouble. We use @types/react, but tfjs-vis uses preact, which provides colliding global JSX definitions.

The problem started with tfjs-vis 0.5.1 (and persists in 1.0.x). I don't understand why things worked with tfjs-vis 0.5.0; still trying to pin down any relevant difference.

Some background on the issue:
preactjs/preact#1036
microsoft/TypeScript#18588 (maybe?)

@davidsoergel davidsoergel added type:bug Something isn't working type:support user support questions labels Mar 19, 2019
@tafsiri
Copy link
Contributor

tafsiri commented Mar 19, 2019

Updating issue after convo with David. Workaround is to delete preact.d.ts in node_modules/preact/dist and node_modules/preact/src

I suspect the preact 8.* typings are just incompatible with react 16s latest typings. But can dig deeper when I get a chance. Either way preact typings should not be relevant for consumers of tfjs-vis.

@davidsoergel
Copy link
Member Author

Yep, thanks. An effective workaround is to add this to package.json:

"scripts": {
    "postinstall": "rimraf node_modules/preact/*/preact.d.ts"
}

That way the irrelevant preact types are automatically deleted after every yarn, and everything works fine. I think this is sufficient to close the bug?

@tafsiri
Copy link
Contributor

tafsiri commented Mar 20, 2019

Thanks David! I might keep it open for a bit just to remind me to investigate typings drift between the projects (though I do think your solution is the right one, react users would always want to use react types). So I might close it soon (maybe i'll remove the bug tag since it has a solution).

@tafsiri tafsiri removed the type:bug Something isn't working label Mar 20, 2019
aslamplr added a commit to aslamplr/mnist-tfjs that referenced this issue Apr 12, 2019
- Add Grommet for UI components
- Fix to work with tfjs-vis (preact JSX type namespace collition) - tensorflow/tfjs#1415

💕💕💕
aslamplr added a commit to aslamplr/mnist-tfjs that referenced this issue Apr 12, 2019
- Add Grommet for UI components
- Fix to work with tfjs-vis (preact JSX type namespace collition) - tensorflow/tfjs#1415

💕💕💕
@tafsiri tafsiri closed this as completed Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vis type:support user support questions
Projects
None yet
Development

No branches or pull requests

2 participants