babel-plugin-typescript-to-proptypes
babel-plugin-typescript-to-proptypes copied to clipboard
Making it work with `create-react-app --template typscript`
I want some help on how to set this up with the `create-react-app --template typescript, I am not sure I am doing something wrong or it's some issue from the package itself
Hello, I believe the following should work:
- Eject CRA (to gain access to babel config)
- Install
babel-plugin-typescript-to-proptypes - Create a
babel.config.jsfile, that contains the babel settings from the Readme.md file. - Remove babel settings from
package.json - Change
process.env.BABEL_ENVto "development" inscripts/build.js, otherwise the proptypes are removed in prod mode - Add
import React from "react";to each component, even if it is not needed anymore when using the new JSX transform. Otherwise the proptypes won't be exported (see https://github.com/milesj/babel-plugin-typescript-to-proptypes/issues/64) - Run
npm run build. Proptypes should still be in the compiled files inbuild/static/js/*.js