Skip to content

About

jscodeshift typescript codemod copilot coding example

Topics

Resources

Stars

94 stars

Watchers

1 watching

Forks

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

Use /jscodeshift SKILL to create your codemod 🤖

Start in Plan Mode and use example prompt to create a new transform with tests:

/jscodeshift

Create new codemod to migrate lodash imports to use deep imports

before:
```ts
import { pluck } from 'lodash';
```

after:
```ts
import pluck from 'lodash/pluck';
```

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

About

jscodeshift typescript codemod copilot coding example

Topics

Resources

Stars

94 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages