Say you want to import something, but only use it for typehinting. This is the plugin for you!
import { MyType } from 'file.d.ts'; // typehints-only
/** @type {MyType} */
const something = {
// ...
};
Turns into
/** @type {MyType} */
const something = {
// ...
};
With npm
npm install --save-dev babel-plugin-strip-typehint-imports
With yarn
npm install --save-dev babel-plugin-strip-typehint-imports
And add the plugin to your .babelrc file
{
"plugins": [
"strip-typehint-imports"
]
}
You can also change which text is used to strip the imports.
{
"plugins": [
["strip-typehint-imports", {
"text": "remove me"
}]
]
}
will remove the following import statement:
import {a} from 'b'; // remove me