Search code examples
typescripttsc

Does TypeScript's tsc create a cache of previously transpiled files?


I created a definition file for greeter.ts, and then a number of other *.ts files. When I ran tsc --project ./tsconfig.tsc.json --declaration it generated *.d.ts files for all of the other *.ts files, except for greeter.d.ts, which I'd manually created. It refused to overwrite it. So, I deleted greeter.d.ts and ran tsc again. It outputs the same error error TS5055: Cannot write file '~/project/greeter.d.ts' because it would overwrite input file., even though the file no longer exists.

So, why is tsc able to overwrite files it previously generated, but not the one I created? Even more, it still thinks the manually created *.d.ts file exists after I deleted it. Logically, there is a cache somewhere, but I haven't found information about it.

Is there a cache of previously transpiled files?


Solution

  • I doubt it creates a cache. I found how it "knows" that I manually created a definition file. In my greeter.ts, I referenced it like so:

    /// <reference path="greeter.d.ts" />
    export class Greeter {
    
      public greeting: string;
      constructor() {
          console.log('Greeter()');
      }
    
      public activate() {
        this.greeting = 'hello worldz';
      }
    }
    

    Removing the reference cleared the error and tsc was able to create the file.