Typescript TS5042 Build: Option 'project' cannot be mixed with source files on a command line

The tsc command can be run in two ways:

  1. With a project parameter, which points to the directory that contains a tsconfig.json. For example: tsc --project ./app. The location of the tsconfig.json determines the set of files that should be included in the compilation. See here for more about the tsconfig.json: http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
  2. With a list of files as the default parameter. For example: tsc MyFile1.ts MyFile2.ts MyFile3.ts.

These two options are incompatible with each other because they both attempt to define which files should be compiled.

What is the command you are using to compile your project? Or are you using an IDE that runs the build for you?

Here's the reference for the tsc compiler options.


i was getting same error but when removed every space in my folders name as shown in path from tsc compiler it now successfully builds.See also this GitHub issue.


I have found a fix that works for me. I have more than one version of Visualstudio at c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\

Open v15.0 and copy the Typescript folder to the v14.0 folder.