I'm trying to compile a typescript into JavaScript using tsc node package module. First of all, I've installed the module using npm install -g typescript.
In my local directory I've created a file called classes.js containing a valid typescript code. When running tsc classes.js I get the following error: Error reading file "./classes.js": File not found
The error doesn't make much sense, since the file exist. Same error is shown when the absolute file path is used. I'm wondering if there is something wrong with tsc module or am I missing something?
The typescript compiler specifically looks for extensions .str and .ts. Here is the code that resolves input file names:
if(!TypeScript.isSTRFile(normalizedPath) && !TypeScript.isTSFile(normalizedPath)) {
normalizedPath += ".ts";
}
The compiler then looks for a file with name normalizedPath, which in your case corresponds to classes.js.ts, which does not exist. In my opinion, the compiler should output a better error message here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With