Last active
June 17, 2021 20:08
-
-
Save hexnickk/40a0ab76676c88a3bc029c65912357d2 to your computer and use it in GitHub Desktop.
Typescript migration helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| # Super dummy script to add @ts-expect-error to all typescript strcit mode errors | |
| # So we are able to migrate with small steps | |
| RET=1 | |
| until [ $RET -eq 0 ]; do | |
| echo 'Running tsc...' | |
| OUT=$(./node_modules/.bin/tsc --noEmit) | |
| RET=$? # will repeat if there are any errors | |
| echo 'Fixing first error...' | |
| echo "$OUT" | | |
| egrep -o '(.*\.tsx)\(([0-9]+)' | # get file & error line | |
| sed 's/(/ /g' | # split file and error line | |
| sort -u -t' ' -k1,1 | # get uniq files, we can't insert multiple file multiple times | |
| # xargs -n 2 bash -c 'echo $0 $1' | |
| xargs -n 2 bash -c 'sed -i "$1s/^/\/\/ @ts-expect-error\n/" $0' # insert //@ts-expect-error | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment