Skip to content

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

Debug

Use the pre-configured VSCode launcher to run tests and debug your transformer.

debugger

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

About

jscodeshift typescript codemod copilot vibe code example

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •