Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
IceCreamYou opened this issue Sep 19, 2017 · 2 comments
Closed

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

IceCreamYou opened this issue Sep 19, 2017 · 2 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@IceCreamYou
Copy link

IceCreamYou commented Sep 19, 2017

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.)

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Sep 19, 2017
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.6 milestone Sep 19, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 19, 2017

this a limitation in our commandline parser. it should however work if you have another argument after it. e.g. tsc --types --pretty.

@mhegazy mhegazy unassigned ghost Sep 19, 2017
@mhegazy mhegazy removed this from the TypeScript 2.6 milestone Sep 19, 2017
@mhegazy mhegazy added Design Limitation Constraints of the existing architecture prevent this from being fixed and removed Bug A bug in TypeScript labels Apr 12, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

IceCreamYou added a commit to IceCreamYou/TypeScript-Handbook that referenced this issue Apr 27, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

4 participants