Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow adding a TS 4.5 style type import #103

Open
IanVS opened this issue Feb 8, 2022 · 7 comments
Open

Feature: Allow adding a TS 4.5 style type import #103

IanVS opened this issue Feb 8, 2022 · 7 comments
Labels
📚 docs Improvements or additions to documentation 📈 enhancement New feature or request 🙏 help wanted Extra attention is needed

Comments

@IanVS
Copy link

IanVS commented Feb 8, 2022

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!

@IanVS
Copy link
Author

IanVS commented Feb 8, 2022

Actually, I wonder if this is even possible. I opened a request at facebook/jscodeshift#481, because I think jscodeshift does not allow this kind of creation.

@danieldelcore
Copy link
Contributor

Yeah, in fact i think this is actually a recast thing! Please LMK if you manage to find a solution :)

@IanVS
Copy link
Author

IanVS commented Mar 15, 2022

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!

@IanVS IanVS closed this as completed Mar 15, 2022
@danieldelcore
Copy link
Contributor

danieldelcore commented Mar 15, 2022

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:

  1. Provide documentation for writing and publishing codemods
  2. Provide tooling & utilities to make it easier to write and run codemods
  3. Provide a library of community codemods, similar to definitelytyped

Would love to pair with you to add this if you're interested in contributing 👍

@danieldelcore danieldelcore reopened this Mar 15, 2022
@danieldelcore danieldelcore added 📚 docs Improvements or additions to documentation 📈 enhancement New feature or request 🙏 help wanted Extra attention is needed labels Mar 15, 2022
@IanVS
Copy link
Author

IanVS commented May 29, 2022

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.

@danieldelcore
Copy link
Contributor

That sounds fantastic! All the best with your talk!! Send me a link to the recording, would love to watch!

@danieldelcore
Copy link
Contributor

Hey @IanVS, how'd your talk go!? Is there a recording or something I can watch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs Improvements or additions to documentation 📈 enhancement New feature or request 🙏 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants