Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript output file without compiling

I have a bunch of JS file that I would like to convert to TS files without having to add any typing or introducing a lot of changes. I know I can use // @ts-ignore on the lines that I want the compiler to ignore, but is there a way to ignore the entire file?

I still would like to output a JS file, but as is, with all the errors ignores.

like image 728
Alkasai Avatar asked Nov 28 '25 03:11

Alkasai


1 Answers

It's easy. Don't rename the file to .ts (until you want to deal with the errors), and use the following configuration

 {
    "compilerOptions": {
      "allowJs": true,
      "checkJs": false,
      "rootDir": "src", 
      "outDir": "dist"
    }
 }

TypeScript will transpile your JavaScript files along with your TypeScript files and provide as much intellisense as possible.

I've answered a similar question in greater detail here: https://stackoverflow.com/a/49640454/1915893

like image 89
Aluan Haddad Avatar answered Nov 29 '25 16:11

Aluan Haddad