Skip to content

[Proposal] [Typescript] Generate Typescript definition files dynamically #10865

@franklixuefei

Description

@franklixuefei

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.

  1. It completely eliminates the need to proactively maintain the type definition files, except for occasional type fixes in the .md files.
  2. Defining types in .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.js

I 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: new featureExpand the scope of the product to solve a new problem.typescript
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions