Compile typescript into javascript?


I have an npm app built with TypeScript. I don’t push the compiled js files to GitHub since the Typescript compiler should handle that. When I run tsc from the npm scripts or even from the console, it doesn’t create the new files. It seems to run the compiler, since it shows compile errors when there are errors. Is this something glitch just doesn’t do?


Hey @szeck87 I remixed the project you sent privately and cannot reproduce this issue. In the console I did the following:

mv dist dist-remixed # move your precompiled files out of the outdir path
tsc # try the typescript compiler in the console
mv dist dit-console # move my console-compiled files out of the way
npm run-script build # use the build script to run the TS compiler
diff dist dist-console # compare the npm-generated files with the console-generated ones
diff dist dist-remixed # compare the npm-generated files with your pre-compiled ones

Both diffs came up empty, which means to me that precompiled == console-generated == npm-generated, so the TypeScript compiler seems to be working as expected.

Are you still having trouble with this?


Yeah, I took a further look in the console and discovered the files are there, the startup issue was a typo on my part in my package.json.

The file UI in glitch isn’t displaying the compiled files, that’s the issue. You had suggested

To get around this you can use the “refresh” command in the console, or add it to your scripts (the child_process module in Node is handy for this).

Running refresh in the console didn’t fix the UI issue. I’m not sure what you mean by using Node’s chid_process to solve it. Can you elaborate?


When you run refresh in the console it should reload the project and that will cause the updated files to show up in the editor UI. BUT… The editor UI will never show files that are in your .gitignore file by design. Since dist is git-ignored you won’t see them in the UI.

What I meant by using child-process is that in your workflow whenever you want to refresh the editor UI you can use child_process.exec() to execute the refresh command automatically. You can also just drop it in one of your existing script by adding && refresh to the command. In any case you’d have to be careful about causing a loop (after you run refresh the project will start again so your prestart script will also run, which could cause your project to re start and your prestart script will run which will …). In any case due to the feature I mentioned above that won’t help you see your dist files in the UI.