Skip to content

Generate Typescript and Flow type definitions from existing prop-types. #1346

Closed
@girishla

Description

@girishla

Are there any plans on providing Typescript type definitions ?

Activity

interactivellama

interactivellama commented on May 4, 2018

@interactivellama
Contributor

There is nothing on the roadmap for *.d.ts files at this time. I'm open to them being added. We would probably need to add some tests that validate them, so that they don't get out of date.

changed the title [-]Typescript Type definitions[/-] [+]Explore Typescript Type definitions[/+] on May 7, 2018
interactivellama

interactivellama commented on May 7, 2018

@interactivellama
Contributor

How can we do this based on propTypes in an automated way?

Also provide Flow typed definitions.

futuremint

futuremint commented on May 7, 2018

@futuremint
Contributor

I tried using dts-gen from Microsoft last week to create Typescript definitions but couldn't get it working using their basic CLI usage on our npm library.

However I'm sure it'll be straightforward to write up a script that uses the source files to generate type definition files from the PropTypes we've already written.

davidlygagnon

davidlygagnon commented on May 7, 2018

@davidlygagnon
Contributor

There is this codemod available to generate flow types from prop-types : https://medium.com/netscape/react-proptypes-to-flow-codemod-9757f5ec5381

. Only caveat is it seems to also removes prop-types... Never used it before but maybe there's a flag that can be passed to leave prop-types as is when converting.

I know I've used this: https://github.com/joarwilk/flowgen before to convert TypeScript defs to flow types, (but that's assuming we have TypeScript defs).

interactivellama

interactivellama commented on May 7, 2018

@interactivellama
Contributor

We might be able to use something from react-docgen AST parser if we need to do something custom.

deleted a comment from stale on Jul 6, 2018
futuremint

futuremint commented on Sep 4, 2018

@futuremint
Contributor

I'm going to work on adding a typedef file in October. I will also look into generating a library definition for flow as well.

deleted a comment from stale on Sep 4, 2018

28 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @futuremint@xoob@dehru@interactivellama@davidlygagnon

        Issue actions

          Generate Typescript and Flow type definitions from existing prop-types. · Issue #1346 · salesforce/design-system-react