-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Simplified help, and enhanced --init
output
#13982
Conversation
--init
output
…e all options generated
here is the output of the help for review purposes: c:\ts>node built\local\tsc.js --help
Version 2.3.0
Syntax: tsc [options] [file ...]
Examples: tsc hello.ts
tsc --outFile file.js file.ts
tsc @args.txt
Options:
-h, --help Print this message.
--all Show all compiler options.
-v, --version Print the compiler's version.
--init Initializes a TypeScript project and creates a tsconfig.json file.
-p FILE OR DIRECTORY, --project FILE OR DIRECTORY Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
--pretty Stylize errors and messages using color and context (experimental).
-w, --watch Watch input files.
-t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'.
-m KIND, --module KIND Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'.
--lib Specify library files to be included in the compilation:
'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'esnext' 'dom' 'dom.iterable' 'webworker' 'scripthost' 'es2015.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.array.include' 'es2017.object' 'es2017.sharedmemory' 'es2017.string' 'esnext.asynciterable'
--allowJs Allow javascript files to be compiled.
--jsx KIND Specify JSX code generation: 'preserve', 'react-native', or 'react'.
-d, --declaration Generates corresponding '.d.ts' file.
--sourceMap Generates corresponding '.map' file.
--outFile FILE Concatenate and emit output to single file.
--outDir DIRECTORY Redirect output structure to the directory.
--removeComments Do not emit comments to output.
--noEmit Do not emit outputs.
--strict Enable all strict type checks.
--noImplicitAny Raise error on expressions and declarations with an implied 'any' type.
--strictNullChecks Enable strict null checks.
--noImplicitThis Raise error on 'this' expressions with an implied 'any' type.
--alwaysStrict Parse in strict mode and emit "use strict" for each source file.
--noUnusedLocals Report errors on unused locals.
--noUnusedParameters Report errors on unused parameters.
--noImplicitReturns Report error when not all code paths in function return a value.
--noFallthroughCasesInSwitch Report errors for fallthrough cases in switch statement.
--types Type declaration files to be included in compilation.
@<file> Insert command line options and files from a file.
c:\ts>node built\local\tsc.js --help --all
Version 2.3.0
Syntax: tsc [options] [file ...]
Examples: tsc hello.ts
tsc --outFile file.js file.ts
tsc @args.txt
Options:
--all Show all compiler options.
--allowJs Allow javascript files to be compiled.
--allowSyntheticDefaultImports Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
--allowUnreachableCode Do not report errors on unreachable code.
--allowUnusedLabels Do not report errors on unused labels.
--alwaysStrict Parse in strict mode and emit "use strict" for each source file.
--baseUrl Base directory to resolve non-absolute module names.
--charset The character set of the input files.
-d, --declaration Generates corresponding '.d.ts' file.
--declarationDir DIRECTORY Output directory for generated declaration files.
--diagnostics Show diagnostic information.
--disableSizeLimit Disable size limitation on JavaScript project.
--downlevelIteration Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.
--emitBOM Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
--emitDecoratorMetadata Enables experimental support for emitting type metadata for decorators.
--experimentalDecorators Enables experimental support for ES7 decorators.
--extendedDiagnostics Show extended diagnostic information.
--forceConsistentCasingInFileNames Disallow inconsistently-cased references to the same file.
-h, --help Print this message.
--importHelpers Import emit helpers from 'tslib'.
--init Initializes a TypeScript project and creates a tsconfig.json file.
--inlineSourceMap Emit a single file with source maps instead of having a separate file.
--inlineSources Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set.
--isolatedModules Unconditionally emit imports for unresolved files.
--jsx KIND Specify JSX code generation: 'preserve', 'react-native', or 'react'.
--jsxFactory Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.
--lib Specify library files to be included in the compilation:
'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'esnext' 'dom' 'dom.iterable' 'webworker' 'scripthost' 'es2015.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.array.include' 'es2017.object' 'es2017.sharedmemory' 'es2017.string' 'esnext.asynciterable'
--listEmittedFiles Print names of generated files part of the compilation.
--listFiles Print names of files part of the compilation.
--locale The locale to use to show error messages, e.g. 'en-us'.
--mapRoot LOCATION Specify the location where debugger should locate map files instead of generated locations.
--maxNodeModuleJsDepth The maximum dependency depth to search under node_modules and load JavaScript files.
-m KIND, --module KIND Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'.
--moduleResolution STRATEGY Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).
--newLine NEWLINE Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix).
--noEmit Do not emit outputs.
--noEmitHelpers Do not generate custom helper functions like __extends in compiled output.
--noEmitOnError Do not emit outputs if any errors were reported.
--noErrorTruncation Do not truncation error messages.
--noFallthroughCasesInSwitch Report errors for fallthrough cases in switch statement.
--noImplicitAny Raise error on expressions and declarations with an implied 'any' type.
--noImplicitReturns Report error when not all code paths in function return a value.
--noImplicitThis Raise error on 'this' expressions with an implied 'any' type.
--noImplicitUseStrict Do not emit 'use strict' directives in module output.
--noLib Do not include the default library file (lib.d.ts).
--noResolve Do not add triple-slash references or module import targets to the list of compiled files.
--noUnusedLocals Report errors on unused locals.
--noUnusedParameters Report errors on unused parameters.
--out FILE [Deprecated] Use '--outFile' instead. Concatenate and emit output to single file
--outDir DIRECTORY Redirect output structure to the directory.
--outFile FILE Concatenate and emit output to single file.
--paths List of path mapping entries for module names to locations relative to the 'baseUrl'.
--plugins List of Language Service plugins.
--preserveConstEnums Do not erase const enum declarations in generated code.
--pretty Stylize errors and messages using color and context (experimental).
-p FILE OR DIRECTORY, --project FILE OR DIRECTORY Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
--reactNamespace [Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit
--removeComments Do not emit comments to output.
--rootDir LOCATION Specify the root directory of input files. Use to control the output directory structure with --outDir.
--rootDirs List of root folders whose combined content represent the structure of the project at runtime.
--skipDefaultLibCheck [Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files.
--skipLibCheck Skip type checking of declaration files.
--sourceMap Generates corresponding '.map' file.
--sourceRoot LOCATION Specify the location where debugger should locate TypeScript files instead of source locations.
--strict Enable all strict type checks.
--strictNullChecks Enable strict null checks.
--stripInternal Do not emit declarations for code that has an '@internal' annotation.
--suppressExcessPropertyErrors Suppress excess property checks for object literals.
--suppressImplicitAnyIndexErrors Suppress noImplicitAny errors for indexing objects lacking index signatures.
-t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'.
--traceResolution Enable tracing of the name resolution process.
--typeRoots List of folders to include type definitions from.
--types Type declaration files to be included in compilation.
-v, --version Print the compiler's version.
-w, --watch Watch input files.
@<file> Insert command line options and files from a file. |
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6149 | ||
}, | ||
"Enable all strict type checks.": { | ||
"Show extended diagnostic information.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"verbose" or "detailed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6152 | ||
}, | ||
"Unconditionally emit imports for unresolved files.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like that's not the only thing this does :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6155 | ||
}, | ||
"The locale to use to show error messages, e.g. 'en-us'.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The locale use when displaying messages to the user (e.g. 'en-us').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6156 | ||
}, | ||
"Do not generate custom helper functions like __extends in compiled output.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes around __extends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6158 | ||
}, | ||
"Do not add triple-slash references or module import targets to the list of compiled files.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or module import targets -> or imported modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6170 | ||
}, | ||
"CommandLine Options": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command-line Options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6172 | ||
}, | ||
"Strict Type Checks": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strict Type-Checking Options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6174 | ||
}, | ||
"SourceMap Options": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source Map
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6178 | ||
}, | ||
"Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide full support for iterables in for-of
, spread, and destructuring when targeting ES5 & ES3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/diagnosticMessages.json
Outdated
"category": "Message", | ||
"code": 6180 | ||
}, | ||
"List of Language Service plugins.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
language service plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/compiler/tsc.ts
Outdated
@@ -227,7 +227,7 @@ namespace ts { | |||
|
|||
if (commandLine.options.help) { | |||
printVersion(); | |||
printHelp(); | |||
printHelp(commandLine.options.all); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels strange that you won't get help output if you only provide --all
. Either check for it as well, give an error if help
is not provided, or create a --help-all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we believe we won't use --all
for something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@DanielRosenwasser, any other comments? |
|
SourceMap should be the only one that is in "Basic", the other source map flags should be under "Source Map Options". it seemed that most users would be interested in setting up source maps, but very few would be interested in the "advanced" source map options. |
You guys realize that |
yes. this was the original apprehension to adding comments to the file. We have since added support for stripping comments in the compiler and the compiler API, we have also seen other tools do that like VSCode for instance. Overall the value and expressiveness of the comments is big, and users are always welcome to define the files themselves, |
TypeScript chose a format that explicitly doesn't support comments only to fight it later :) But I understand, in our own projects, we have a similar dilemma: JSON is pretty close to being a great config format, except for comments. |
This change includes a few changes:
--help --all
to show all help optionstsc --init
produce a file with comments for "popular" options and will arrange them in categories, e.g.Strict Checks
,Module Resolution
,SourceMap Options
The result of
tsc --init
looks something like: