Skip to content

Commit 8f8fec4

Browse files
authored
Rename switch --emitDeclarationsOnly to --emitDeclarationOnly (#21651)
* Rename `--emitDeclarationsOnly` to `--renameDeclarationOnly` * Rename test files
1 parent c7b86e8 commit 8f8fec4

21 files changed

+31
-31
lines changed

Diff for: src/compiler/commandLineParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ namespace ts {
187187
description: Diagnostics.Generates_corresponding_d_ts_file,
188188
},
189189
{
190-
name: "emitDeclarationsOnly",
190+
name: "emitDeclarationOnly",
191191
type: "boolean",
192192
category: Diagnostics.Advanced_Options,
193193
description: Diagnostics.Only_emit_d_ts_declaration_files,

Diff for: src/compiler/emitter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ namespace ts {
135135

136136
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) {
137137
// Make sure not to write js file and source map file if any of them cannot be written
138-
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit && !compilerOptions.emitDeclarationsOnly) {
138+
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit && !compilerOptions.emitDeclarationOnly) {
139139
if (!emitOnlyDtsFiles) {
140140
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle);
141141
}

Diff for: src/compiler/program.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2201,13 +2201,13 @@ namespace ts {
22012201
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
22022202
}
22032203

2204-
if (options.emitDeclarationsOnly) {
2204+
if (options.emitDeclarationOnly) {
22052205
if (!options.declaration) {
2206-
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDeclarationsOnly", "declarations");
2206+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDeclarationOnly", "declarations");
22072207
}
22082208

22092209
if (options.noEmit) {
2210-
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationsOnly", "noEmit");
2210+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
22112211
}
22122212
}
22132213

@@ -2233,7 +2233,7 @@ namespace ts {
22332233
const emitHost = getEmitHost();
22342234
const emitFilesSeen = createMap<true>();
22352235
forEachEmittedFile(emitHost, (emitFileNames) => {
2236-
if (!options.emitDeclarationsOnly) {
2236+
if (!options.emitDeclarationOnly) {
22372237
verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen);
22382238
}
22392239
verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen);

Diff for: src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4025,7 +4025,7 @@ namespace ts {
40254025
/** configFile is set as non enumerable property so as to avoid checking of json source files */
40264026
/* @internal */ readonly configFile?: JsonSourceFile;
40274027
declaration?: boolean;
4028-
emitDeclarationsOnly?: boolean;
4028+
emitDeclarationOnly?: boolean;
40294029
declarationDir?: string;
40304030
/* @internal */ diagnostics?: boolean;
40314031
/* @internal */ extendedDiagnostics?: boolean;

Diff for: src/harness/harness.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1255,9 +1255,9 @@ namespace Harness {
12551255

12561256
if (result.errors.length === 0) {
12571257
if (options.declaration) {
1258-
if (options.emitDeclarationsOnly) {
1258+
if (options.emitDeclarationOnly) {
12591259
if (result.files.length > 0 || result.declFilesCode.length === 0) {
1260-
throw new Error("Only declaration files should be generated when emitDeclarationsOnly:true");
1260+
throw new Error("Only declaration files should be generated when emitDeclarationOnly:true");
12611261
}
12621262
}
12631263
else if (result.declFilesCode.length !== result.files.length) {
@@ -1664,7 +1664,7 @@ namespace Harness {
16641664
}
16651665

16661666
export function doJsEmitBaseline(baselinePath: string, header: string, options: ts.CompilerOptions, result: CompilerResult, tsConfigFiles: Harness.Compiler.TestFile[], toBeCompiled: Harness.Compiler.TestFile[], otherFiles: Harness.Compiler.TestFile[], harnessSettings: Harness.TestCaseParser.CompilerSettings) {
1667-
if (!options.noEmit && !options.emitDeclarationsOnly && result.files.length === 0 && result.errors.length === 0) {
1667+
if (!options.noEmit && !options.emitDeclarationOnly && result.files.length === 0 && result.errors.length === 0) {
16681668
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
16691669
}
16701670

Diff for: tests/baselines/reference/api/tsserverlibrary.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ declare namespace ts {
23012301
charset?: string;
23022302
checkJs?: boolean;
23032303
declaration?: boolean;
2304-
emitDeclarationsOnly?: boolean;
2304+
emitDeclarationOnly?: boolean;
23052305
declarationDir?: string;
23062306
disableSizeLimit?: boolean;
23072307
downlevelIteration?: boolean;

Diff for: tests/baselines/reference/api/typescript.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ declare namespace ts {
23012301
charset?: string;
23022302
checkJs?: boolean;
23032303
declaration?: boolean;
2304-
emitDeclarationsOnly?: boolean;
2304+
emitDeclarationOnly?: boolean;
23052305
declarationDir?: string;
23062306
disableSizeLimit?: boolean;
23072307
downlevelIteration?: boolean;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5052: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declarations'.
2+
3+
4+
!!! error TS5052: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declarations'.
5+
==== tests/cases/compiler/hello.ts (0 errors) ====
6+
var hello = "yo!";
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5052: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declarations'.
2+
error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
3+
4+
5+
!!! error TS5052: Option 'emitDeclarationOnly' cannot be specified without specifying option 'declarations'.
6+
!!! error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.
7+
==== tests/cases/compiler/hello.ts (0 errors) ====
8+
var hello = "yo!";
9+

Diff for: tests/baselines/reference/declFileEmitDeclarationsOnlyError1.errors.txt

-7
This file was deleted.

Diff for: tests/baselines/reference/declFileEmitDeclarationsOnlyError2.errors.txt

-9
This file was deleted.

Diff for: tests/cases/compiler/declFileEmitDeclarationsOnly.ts renamed to tests/cases/compiler/declFileEmitDeclarationOnly.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @declaration: true
2-
// @emitDeclarationsOnly: true
2+
// @emitDeclarationOnly: true
33

44
// @filename: helloworld.ts
55
const Log = {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @emitDeclarationsOnly: true
1+
// @emitDeclarationOnly: true
22

33
// @filename: hello.ts
44
var hello = "yo!";
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @noEmit: true
2-
// @emitDeclarationsOnly: true
2+
// @emitDeclarationOnly: true
33

44
// @filename: hello.ts
55
var hello = "yo!";

0 commit comments

Comments
 (0)