Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript *.ts not working?

Tags:

typescript

I can't seem to figure out why when running

tsc *.ts

isn't working. It comes with the error: TS6053: File '*.ts' not found. How do I compile all of the .ts files in a folder? Thanks!

like image 551
NeuronButter Avatar asked Jan 27 '23 23:01

NeuronButter


2 Answers

When running tsc from the command line without a tsconfig present, you need to pass it a file name, i.e. app.ts - it will walk the dependencies for you, so you don't need to use a wildcard.

If you have a tsconfig.json file, just run tsc with no file name argument and it will use the config, which can contain wildcards.

like image 112
Fenton Avatar answered Jan 31 '23 21:01

Fenton


Just type tsc without anything. It will compile all .ts files into .js files. If you want to bundle them, type tsc --outFile mybundle.js.

Please note that in this case, bundling only means that all your .js code will be placed in one file. For more elaborate options it's better to create the tsconfig.json, as others have mentioned.

like image 36
Kokodoko Avatar answered Jan 31 '23 21:01

Kokodoko