Open IanVS opened 2 years ago
Actually, I wonder if this is even possible. I opened a request at https://github.com/facebook/jscodeshift/issues/481, because I think jscodeshift does not allow this kind of creation.
Yeah, in fact i think this is actually a recast thing! Please LMK if you manage to find a solution :)
I was able to find a way to accomplish what I was trying to do, and published an npm package: https://www.npmjs.com/package/type-import-codemod
It didn't quite seem to fit with the goals of this project (it's not something intended to use with a particular library/package), but I did start off down that road at first and the scaffolding from the cli was helpful, so thanks!
That's actually really cool lib, thanks for sharing!
I can actually see this being incorporated into this library in a few ways!
Just for context, the goal of this project is to do the following:
Would love to pair with you to add this if you're interested in contributing 👍
I haven't forgotten about this issue, I've just been preoccupied with other things lately. But, I'm giving a talk at a meetup about codemods using my project above as an example, and will mention CodeshiftCommunity as well. I hope to come back to this once things have settled down a bit.
That sounds fantastic! All the best with your talk!! Send me a link to the recording, would love to watch!
Hey @IanVS, how'd your talk go!? Is there a recording or something I can watch!
I'm trying to write a codemod that changes from the old style of type imports:
import type {MyType} from './types';
to the newer style:
import {type MyType} from './types';
I saw you have some import helpers, but don't see anything that allows creation of an ImportSpecifier with
importKind: "type"
, which I think is what is needed. Maybe you could consider adding it?Thanks!