Skip to content

Commit 39311da

Browse files
authored
fix(36385): return failed exit code if tsconfig doesn't exist and there are no input files. (#36474)
1 parent 8eee8db commit 39311da

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

src/executeCommandLine/executeCommandLine.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,12 @@ namespace ts {
243243
if (commandLine.fileNames.length === 0 && !configFileName) {
244244
if (commandLine.options.showConfig) {
245245
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, normalizePath(sys.getCurrentDirectory())));
246-
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
247246
}
248247
else {
249248
printVersion(sys);
250249
printHelp(sys, getOptionsForHelp(commandLine));
251-
return sys.exit(ExitStatus.Success);
252250
}
251+
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
253252
}
254253

255254
const currentDirectory = sys.getCurrentDirectory();
@@ -739,4 +738,4 @@ namespace ts {
739738

740739
return;
741740
}
742-
}
741+
}

src/testRunner/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"unittests/tsc/declarationEmit.ts",
130130
"unittests/tsc/incremental.ts",
131131
"unittests/tsc/listFilesOnly.ts",
132+
"unittests/tsc/runWithoutArgs.ts",
132133
"unittests/tscWatch/consoleClearing.ts",
133134
"unittests/tscWatch/emit.ts",
134135
"unittests/tscWatch/emitAndErrorUpdates.ts",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ts {
2+
describe("unittests:: tsc:: runWithoutArgs::", () => {
3+
verifyTsc({
4+
scenario: "runWithoutArgs",
5+
subScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped",
6+
fs: () => loadProjectFromFiles({}),
7+
commandLineArgs: []
8+
});
9+
});
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//// [/lib/initial-buildOutput.txt]
2+
/lib/tsc
3+
Version 3.8.0-dev
4+
Syntax: tsc [options] [file...]
5+
6+
Examples: tsc hello.ts
7+
tsc --outFile file.js file.ts
8+
tsc @args.txt
9+
tsc --build tsconfig.json
10+
11+
Options:
12+
-h, --help Print this message.
13+
-w, --watch Watch input files.
14+
--pretty Stylize errors and messages using color and context (experimental).
15+
--all Show all compiler options.
16+
-v, --version Print the compiler's version.
17+
--init Initializes a TypeScript project and creates a tsconfig.json file.
18+
-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'.
19+
-b, --build Build one or more projects and their dependencies, if out of date
20+
-t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'.
21+
-m KIND, --module KIND Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'.
22+
--lib Specify library files to be included in the compilation.
23+
'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' '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' 'es2017.intl' 'es2017.typedarrays' 'es2018.asyncgenerator' 'es2018.asynciterable' 'es2018.intl' 'es2018.promise' 'es2018.regexp' 'es2019.array' 'es2019.object' 'es2019.string' 'es2019.symbol' 'es2020.bigint' 'es2020.promise' 'es2020.string' 'es2020.symbol.wellknown' 'esnext.array' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint'
24+
--allowJs Allow javascript files to be compiled.
25+
--jsx KIND Specify JSX code generation: 'preserve', 'react-native', or 'react'.
26+
-d, --declaration Generates corresponding '.d.ts' file.
27+
--declarationMap Generates a sourcemap for each corresponding '.d.ts' file.
28+
--sourceMap Generates corresponding '.map' file.
29+
--outFile FILE Concatenate and emit output to single file.
30+
--outDir DIRECTORY Redirect output structure to the directory.
31+
--removeComments Do not emit comments to output.
32+
--noEmit Do not emit outputs.
33+
--strict Enable all strict type-checking options.
34+
--noImplicitAny Raise error on expressions and declarations with an implied 'any' type.
35+
--strictNullChecks Enable strict null checks.
36+
--strictFunctionTypes Enable strict checking of function types.
37+
--strictBindCallApply Enable strict 'bind', 'call', and 'apply' methods on functions.
38+
--strictPropertyInitialization Enable strict checking of property initialization in classes.
39+
--noImplicitThis Raise error on 'this' expressions with an implied 'any' type.
40+
--alwaysStrict Parse in strict mode and emit "use strict" for each source file.
41+
--noUnusedLocals Report errors on unused locals.
42+
--noUnusedParameters Report errors on unused parameters.
43+
--noImplicitReturns Report error when not all code paths in function return a value.
44+
--noFallthroughCasesInSwitch Report errors for fallthrough cases in switch statement.
45+
--types Type declaration files to be included in compilation.
46+
--esModuleInterop Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
47+
@<file> Insert command line options and files from a file.
48+
exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped
49+
50+

0 commit comments

Comments
 (0)