Reputation: 4133
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?
Upvotes: 3
Views: 2936
Reputation: 8074
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.
Upvotes: 3
Reputation: 4133
Apparently the tsc node module works only when the compiled typescript file has ts extension. I believe this is a temporary limitation which could be fixed in future versions of tsc.
Upvotes: 0