Skip to content

Error if command-line options are specified when a tsconfig.json is present #62197

@DanielRosenwasser

Description

@DanielRosenwasser

From #54500:

Currently if you run tsc foo.ts in a folder where a tsconfig.json exists, the tsconfig file is completely ignored. This is very confusing. The intended meaning of this is also unclear; it could be that you want to use the compilerOptions of the config but not the files and/or include and/or exclude.

For clarity, in 6.0, if you run tsc in a directory with a tsconfig.json, an error will be issued instead.

tsconfig.json is present but will not be loaded if files are specified on the commandline. Use --ignore-config to skip this error

Basically, it should be okay to run

  • tsc -p tsconfig.json [other options] - the user has explicitly opted into using the tsconfig.json, but wants to override some options (even files)
  • tsc with no options - regardless of what is run (probably continue just show a basic help screen)

But if you run without -p/--project, you should receive an error if there is a tsconfig.json present and it may be a mistake to build without your project; and that if it was intentional to ignore it, specify --ignoreConfig.

About --ignoreConfig

  • It should be okay to have this option even if there is no tsconfig in the CWD
  • I don't know if it should be called --ignoreProject instead of --ignoreConfig
  • I don't know if we can error if this option is specified within the tsconfig.json, but that probably would be ideal.

Metadata

Metadata

Assignees

Labels

Breaking ChangeWould introduce errors in existing codeCommittedThe team has roadmapped this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions