Closed RIP21 closed 5 years ago
Hi @RIP21!
We translate the example import clause into var Dictionary = require('lodash/Dictionary')
. If I recall there should be another way to import types other than the ESM syntax. If there is you should use the alternative syntax to import types.
That would be nice to have an example TBH :/ Because I think I will be not the last person to ask such a question. I wasn't able to find an answer tho.
I assume this syntax should work.
type MyType = import('mymodule').MyType;
const myValue: import('mymodule').MyType;
If anyone needs an explicit example for how to do this:
import { orderBy } from 'lodash';
import type { Dictionary } from 'lodash';
Notice the type
keyword. That is the distinction that the plugin uses in determining what is a lodash function.
If you import some Types from
lodash
like that.import { orderBy, Dictionary } from 'lodash'
babel-plugin-lodash
throws an error.Will be nice to handle somehow exported Types. Or just stripe them away, since they are not affecting compilation of
babel-typescript-plugin
since he doesn't care about types etc. He just outputs the JS code not looking attsconfig.json
or whatever. Or maybe ordering of plugins matter? Don't know.