-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Proposal] [Typescript] Generate Typescript definition files dynamically #10865
Comments
Hi @franklixuefei, thanks for the kind words. I confess I'm a little confused by this approach... to me it's counterintuitive to start with a completely free text format like
I believe we can kill all these birds with one stone: write the implementation in |
@pelotom The documentation is generated by the propTypes definitions. We do no longer use flow. Don't forget the fourth bird: the flow type definition that would be ideally automatically generated. |
Do you mean proptypes? |
Ah, I thought we had given up on supporting Flow. In that case it seems like we have 5 birds, because we'd ideally generate propTypes too, no? |
@pelotom Yeah, it's not a priority to support Flow. But exploring the field of automatically generating the types. Someone might be interested in jumping in to do the job with Flow.
Yeah sure :). Given we have to make tradeoffs, here is how I think each bird relates to each other. The sum of the priorities equals 100. By priority, I mean, how much value I think it brings to the project. Of course, the execution is a way different story:
|
@pelotom Writing in pure ts would definitely solve the type definition issues for good, given that we do not support Flow anymore. But I can imagine that would be a lot of work porting to typescript. I think it's a tradeoff. I agree with @oliviertassinari regarding the priority, but I think we should still give Typescript a bit more priority :-D. Look at the numbers: |
This is the last progress update on prototyping typescript: #9561
I believe it to be possible now to accomplish the incremental switch. There may be one or two issues with the way we stub/replace methods in testing, but otherwise the PR mentioned above is the right direction with babel 7. We need to use babel 7 for the optimizations for a bundled build, but we do not if we are going to just build/release ES modules. Regardless, I worked out a lot of kinks in the build/test process that could be referenced easily from the old fork and applied to a new effort. I don't a rebase will have any use, but eyeballing a merge against v1-beta might be interesting. As you might expect - I am in support of moving to typescript. |
I'm closing, we have started to go in the other direction: use TypeScript as the source of truth to generate the prop-types and API docs. A big thanks to @merceyz for starting this effort. I think that we can close now. |
Hi,
material-ui
has become my favorite opensource project since early this year. The community is really active and responsive, thanking to all the contributors and members, especially @oliviertassinari for maintaining the repo and developing new features, and @pelotom for maintaining the Typescript definition files, and most importantly, it implements the Material Design so well.Recently I've been taking a deep look at devextreme-reactive's work on the material-ui grid, and they support Typescript projects by dynamically generating the
.d.ts
files. Those type definition files are generated with each release by parsing the.md
files that define the types for all the components across the project. I think this approach is really appealing for two reasons..md
files..md
files will not only be beneficial for generating the type definition files, but it's also great as a documentation because that's what.md
files are for. In the future, if we need to add new features or components, we just need to remember to also include them and their types correctly in the corresponding.md
files, and boom, the type definition files will automatically be generated in the next release. One stone, two birds.FYI - this is their
.d.ts
file generating script - https://github.com/DevExpress/devextreme-reactive/blob/master/scripts/ts-generator.jsI know this would be some work if we ever want to go on this path, because we need to write the
.md
file for each component and then write the script to parse them into.d.ts
files, but it would definitely pay off.The text was updated successfully, but these errors were encountered: