Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chimurai/jscodeshift-typescript-example

Repository files navigation

jscodeshift-typescript-example

TypeScript all the way πŸš€

Example usage of jscodeshift for TypeScript with TypeScript:

  • TypeScript target files *.ts
  • TypeScript transformer
  • TypeScript test files
  • TypeScript fixtures

TypeScript transformer

Strongly typed code and code completion with @types/jscodeshift

code-completion

Vibe Code Your jscodeshift Codemod πŸ€–

With .github/copilot-instructions.md and .github/prompts/new-transformer.prompt.md you can vibe code your jscodeshift codemod.

Example prompt to create a new transform with tests:

Create a new transform to add a post-fix "funny" to class name
before:
```ts
class Foo {}
```
after:
```ts
class FooFunny {}
```

Installation

npm i

Run a codemod

npx jscodeshift -t ./src/simple-rename.ts --extensions=ts --parser=ts **/*.ts --print --dry

Omit --dry to write the transformed source back to disk.

Test

npm test

Test and Debug with Vitest

Install the Vitest VSCode extension to test and debug your transformer.

jscodeshift-vitest

Behind the scenes

Use @typescript-eslint/parser in https://astexplorer.net when working with the jscodeshift's parser="ts"

By default jscodeshift will use the babel parser (@babel/parser)

Resources & Inspiration

Awesome lists

Contributors 4

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /