Skip to content

Instantly share code, notes, and snippets.

@pmayur
Last active September 15, 2021 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmayur/8294679681ceb0eacbd6a720d7c420d8 to your computer and use it in GitHub Desktop.
Save pmayur/8294679681ceb0eacbd6a720d7c420d8 to your computer and use it in GitHub Desktop.
converting js to ts

Converting JS to TS

  • Perform tsc --init in the repo for initiating a tsconfig.json file
  • Edit tsconfig.json config as per required
  • Use the following scripts to convert js files to ts one by one
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
  • Use the following script to add // @ts-nocheck comment on top of all ts files to avoid immediate ts errors or don't convert them to ts
for f in **/*.ts; do echo "// @ts-nocheck$(cat "$f")" > "$f"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment