-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow extracting meta data from typescript components #719
Comments
Good idea! @Marc-Andre-Rivet do you see any blockers to allowing this? We already support flow, I can imagine us running into problems with complex types but presumably as long as people stay within reason we should be able to handle it. |
This has been on my radar for a while and been looking at the available options periodically. Last time I've tried this the types were not pulled correctly past a certain complexity and was having trouble with imported types. Being based on the Babel AST, some information was getting lost along the way. @andrenanninga is pointing to a different implementation/solution than what I tried. Would need testing but if it works I'm 100% for it. If this works fine with the table, I'd argue it will probably be fine with anything we can throw at it. |
I'll put this on the tech roadmap for tracking. |
Looking at this:
A partial solution that works to solve both the TS typing needs and the runtime prop types needs is using All in all, there are definite upsides to improve direct TS support but want to make it clear that a component developer will lose access to some Dash features (DevTools) in doing so. The duck-typing nature of TS does not make this something we can fix later. |
Is there any progress here ?. We have some typescript React components that we'll like to use in dash. I'm currently publishing my typescript components, and then wrapping them in plain JS components. |
@chabb I last had a look at this in ~November, support was still not quite there but there is progress being made. I haven't had the time to look since. The DataTable suffers from the same situation you describe above, having to duplicate the PropTypes into TypeScript types. I'll try and have another look at this in the next couple of weeks. Better TS support would allow significant 🔪🌴🐫 in our codebase too. |
Since type annotations in Python 3+ have taken inspiration from TypeScript, there is some isomorphism between the two. Due to this, another feature this issue could potentially enable (in Dash 2+ when Python 2.7 support is dropped) is to generate type annotated Dash (Python) components based on the TypeScript type definitions. Advantages:
|
Just wanted to link this here, seem like serious progress is being made on this front! 🥳 |
Looks like we forgot to close this with #1956 😄 |
We would like to use
dash-generate-components
on some Typescript components to allow our Python developers to use them in their Dash code. We have a custom pipeline to transpile the Typescript components to a bundle but we're currently blocked by this line of code:dash/dash/extract-meta.js
Line 63 in ec1576c
Extracting metadata from components is currently only allowed for
.js
and.jsx
files. However react-docgen has no issues extracting metadata from Flow or Typescript.Would you support the addition of
.ts
and.tsx
files to this filter. This would allow us to continue using Typescript.Example typescript code
Dev.jsx
(Currently I am saving this as
Dev.jsx
to allow the extracting of metadata.)Test.py
The text was updated successfully, but these errors were encountered: