babel-plugin-typescript-to-proptypes icon indicating copy to clipboard operation
babel-plugin-typescript-to-proptypes copied to clipboard

Rename import

Open jamesmsk opened this issue 3 years ago • 2 comments

I'm using this package to have a react js copy of my react typescript components. Is it possible to control the import name?

currently its

import _pt from 'prop-types';

I would like to have control of name instead of _pt

jamesmsk avatar Jan 18 '22 18:01 jamesmsk

@jamesmsk If an import already exists, the plugin will use that name, otherwise no.

Curious why you need this? This is an abstraction that isn't used directly.

milesj avatar Jan 18 '22 20:01 milesj

@jamesmsk If an import already exists, the plugin will use that name, otherwise no.

Curious why you need this? This is an abstraction that isn't used directly.

Our mono repo's react components are all written in TypeScript and we needed to compensate for contributors who do not work with TypeScript. Readability and speed of development are the reasons for this. When I transpile from React TS to JS, I want the contributors to have a js version of the source file that they can comprehend quickly. So, in this example, I wanted babel to punch out js files with import PropTypes from 'prop-types to keep with the syntax they are historically using.

jamesmsk avatar Jan 18 '22 21:01 jamesmsk