Skip to content

tsc --types does not support passing no types #18581

Closed
@IceCreamYou

Description

@IceCreamYou

TypeScript Version: 2.5.2

Code

$ touch ./test.ts
$ tsc ./test.ts --types
error TS6044: Compiler option 'types' expects an argument.
$ tsc ./test.ts --types=
error TS5023: Unknown compiler option '--types='.
$ tsc ./test.ts --types ""
error TS6044: Compiler option 'types' expects an argument.
$ tsc ./test.ts --types=[]
error TS5023: Unknown compiler option '--types=[]'.
$ tsc ./test.ts --types="[]"
error TS5023: Unknown compiler option '--types=[]'.
$ tsc ./test.ts --types
error TS6044: Compiler option 'types' expects an argument.
$ tsc ./test.ts --types []
error TS2688: Cannot find type definition file for '[]'.
$ tsc ./test.ts --types ,
error TS2688: Cannot find type definition file for ''.

Expected behavior:
I'm not sure of the exact syntax and no one seems to have done this online, but it should be possible to pass no types to the compiler without using tsconfig.json.

This matters because, as discussed in #11917, the default TypeScript 2.x behavior is to include everything in /node_modules/@types as typings, and this is undesirable behavior for a project of any meaningful size.

Actual behavior:
The compiler fails when passed --types with no arguments. I assume that it also fails with empty --lib, --typeRoots, and --rootDirs.

(Surprisingly, the last command above actually spits out a .js file, but it fails harder on a nontrivial codebase.)

This matters to me because I'm using grunt-ts which only supports the --types flag through specifying an additionalFlags string (edit: looks like it has undocumented support for types but it results in the same error TS6044: Compiler option 'types' expects an argument. error since the config just builds a string that gets executed on the command line.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions