Using --noResolve

Using --noResolve

Normally the compiler will attempt to resolve all module imports before it starts the compilation process. Every time it successfully resolves an import to a file, the file is added to the set of files the compiler will process later on.

The --noResolve compiler options instructs the compiler not to “add” any files to the compilation that were not passed on the command line. It will still try to resolve the module to files, but if the file as not specified, it will not be included.

For instance:

app.ts

import * as A from "moduleA" // OK, 'moduleA' passed on the command-line
import * as B from "moduleB" // Error TS2307: Cannot find module 'moduleB'.
tsc app.ts moduleA.ts --noResolve

Compiling app.ts using --noResolve should result in:

  • Correctly finding moduleA as it was passed on the command-line.
  • Error for not finding moduleB as it was not passed.
doc_TypeScript
2016-10-04 19:25:43
Comments
Leave a Comment

Please login to continue.