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

End-user instructions? #19

Closed
dandv opened this issue Apr 19, 2020 · 3 comments
Closed

End-user instructions? #19

dandv opened this issue Apr 19, 2020 · 3 comments

Comments

@dandv
Copy link

dandv commented Apr 19, 2020

How should this package be used?

Is this library equivalent to @gcanti's prop-types-ts or babel-plugin-typescript-to-proptypes from @milesj?

@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented Apr 22, 2020

@dandv if you're currently in a rush to use this, I'd say take a look at how it's being used in https://github.com/mui-org/material-ui/ for the time being.

@merceyz
Copy link
Owner

merceyz commented Apr 24, 2020

This project was mostly made to get rid of the PropTypes from the TypeScript demos of Material-UI (mui/material-ui#16521).

How should this package be used?

I haven't really documented the project but there are tests that showcase how to use it [1]. You can also look at how it's setup in Material-UI to handle their needs [2][3]

  1. https://github.com/merceyz/typescript-to-proptypes/blob/66f228715a14dd5883d7c06a2b19e6439938973f/test/index.test.ts
  2. https://github.com/mui-org/material-ui/blob/2231349c302a089cc556614ff562b02a729b1e77/docs/scripts/formattedTSDemos.js
  3. https://github.com/mui-org/material-ui/blob/2231349c302a089cc556614ff562b02a729b1e77/scripts/generateProptypes.ts

Is this library equivalent to gcanti's prop-types-ts or babel-plugin-typescript-to-proptypes from milesj?

No, prop-types-ts requires you to write special syntax to get both types and PropTypes while babel-plugin-typescript-to-proptypes can only get info from the current file. This project uses the TypeScript compiler API to get all the information it needs from your entire project and builds up the PropTypes from it.

@aschmoe
Copy link

aschmoe commented Aug 25, 2023

For anyone coming upon this PR / comment later, here is an example usage:

https://gist.github.com/aschmoe/81e51ca4406a2ffef0019f7260d6d14b

working as of:"typescript-to-proptypes": "^2.2.1" (though definitely struggles with complicated type definitions, unsurprisingly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants