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!
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.
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.
I faced the same problem today as you have mentioned, while executing 2 files within a folder which I created some 2-3 months back when started learning Angular. That time I didn't face this issue.
NOTE: That file was un-touched after first time modification and it was successfully executed that time.
I am sure that, below solution is not the ideal one but still it worked for me today.
Scenario: I have a folder which contains "LikesComponent.ts" and "main.ts" file. And I want to execute both my TS files and get the output. So I executed
tsc *.ts && node main.js
I encountered
error TS6053: File '*.ts' not found.
Found 1 error.
But when I executed below command, it worked !!!
tsc LikesComponent.ts main.ts && node main.js
Well, I don't think that is the solution, which is marked as correct, you might new to angular and following Mosh tutorials,
The solution would be just execute the root file where you have imported all other modules, in my scenario, it is main.ts file and below is how I executed it
$tsc main.ts && node main.js
you can use this on linux:
ls *.ts | xargs tsc
The xargs command convert the output from the ls command into an argument for the tsc command.
Note that subfolders also work:
ls src/*.ts | xargs tsc
*
is a shell expansion feature.tsc --rootDir <folder>
. Better place to define this istsconfig.json
and then you just give thetsc
to compile all.