Skip to content

Commit 5ea2cea

Browse files
committed
Merge pull request #3208 from Microsoft/updateSingleCompilationFlagName
Update singleCompilation flag name to isolatedModules
2 parents 91f69d7 + 6057a91 commit 5ea2cea

File tree

94 files changed

+295
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+295
-295
lines changed

Diff for: src/compiler/checker.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ module ts {
732732
let target = resolveAlias(symbol);
733733
if (target) {
734734
let markAlias =
735-
(target === unknownSymbol && compilerOptions.separateCompilation) ||
735+
(target === unknownSymbol && compilerOptions.isolatedModules) ||
736736
(target !== unknownSymbol && (target.flags & SymbolFlags.Value) && !isConstEnumOrConstEnumOnlyModule(target));
737737

738738
if (markAlias) {
@@ -8889,7 +8889,7 @@ module ts {
88898889
// serialize the type metadata.
88908890
if (node && node.kind === SyntaxKind.TypeReference) {
88918891
let type = getTypeFromTypeNode(node);
8892-
let shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation;
8892+
let shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules;
88938893
if (!type || (!shouldCheckIfUnknownType && type.flags & (TypeFlags.Intrinsic | TypeFlags.NumberLike | TypeFlags.StringLike))) {
88948894
return;
88958895
}
@@ -10054,7 +10054,7 @@ module ts {
1005410054
}
1005510055
}
1005610056

10057-
if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) {
10057+
if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) {
1005810058
// Check that base type can be evaluated as expression
1005910059
checkExpressionOrQualifiedName(baseTypeNode.expression);
1006010060
}
@@ -10470,8 +10470,8 @@ module ts {
1047010470
computeEnumMemberValues(node);
1047110471

1047210472
let enumIsConst = isConst(node);
10473-
if (compilerOptions.separateCompilation && enumIsConst && isInAmbientContext(node)) {
10474-
error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided);
10473+
if (compilerOptions.isolatedModules && enumIsConst && isInAmbientContext(node)) {
10474+
error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided);
1047510475
}
1047610476

1047710477
// Spec 2014 - Section 9.3:
@@ -10561,7 +10561,7 @@ module ts {
1056110561
if (symbol.flags & SymbolFlags.ValueModule
1056210562
&& symbol.declarations.length > 1
1056310563
&& !isInAmbientContext(node)
10564-
&& isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) {
10564+
&& isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) {
1056510565
let firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
1056610566
if (firstNonAmbientClassOrFunc) {
1056710567
if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
@@ -11661,7 +11661,7 @@ module ts {
1166111661

1166211662
function isAliasResolvedToValue(symbol: Symbol): boolean {
1166311663
let target = resolveAlias(symbol);
11664-
if (target === unknownSymbol && compilerOptions.separateCompilation) {
11664+
if (target === unknownSymbol && compilerOptions.isolatedModules) {
1166511665
return true;
1166611666
}
1166711667
// const enums and modules that contain only const enums are not considered values from the emit perespective

Diff for: src/compiler/commandLineParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module ts {
142142
paramType: Diagnostics.LOCATION,
143143
},
144144
{
145-
name: "separateCompilation",
145+
name: "isolatedModules",
146146
type: "boolean",
147147
},
148148
{

Diff for: src/compiler/diagnosticInformationMap.generated.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ module ts {
165165
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
166166
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
167167
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
168-
Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." },
169-
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
168+
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
169+
Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." },
170170
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
171171
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
172172
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
@@ -449,11 +449,11 @@ module ts {
449449
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
450450
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
451451
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
452-
Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." },
453-
Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." },
454-
Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." },
455-
Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." },
456-
Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
452+
Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." },
453+
Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." },
454+
Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." },
455+
Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." },
456+
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
457457
Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." },
458458
Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." },
459459
Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." },

Diff for: src/compiler/diagnosticMessages.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,11 @@
647647
"category": "Error",
648648
"code": 1207
649649
},
650-
"Cannot compile namespaces when the '--separateCompilation' flag is provided.": {
650+
"Cannot compile namespaces when the '--isolatedModules' flag is provided.": {
651651
"category": "Error",
652652
"code": 1208
653653
},
654-
"Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": {
654+
"Ambient const enums are not allowed when the '--isolatedModules' flag is provided.": {
655655
"category": "Error",
656656
"code": 1209
657657
},
@@ -1785,23 +1785,23 @@
17851785
"category": "Error",
17861786
"code": 5042
17871787
},
1788-
"Option 'sourceMap' cannot be specified with option 'separateCompilation'.": {
1788+
"Option 'sourceMap' cannot be specified with option 'isolatedModules'.": {
17891789
"category": "Error",
17901790
"code": 5043
17911791
},
1792-
"Option 'declaration' cannot be specified with option 'separateCompilation'.": {
1792+
"Option 'declaration' cannot be specified with option 'isolatedModules'.": {
17931793
"category": "Error",
17941794
"code": 5044
17951795
},
1796-
"Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": {
1796+
"Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": {
17971797
"category": "Error",
17981798
"code": 5045
17991799
},
1800-
"Option 'out' cannot be specified with option 'separateCompilation'.": {
1800+
"Option 'out' cannot be specified with option 'isolatedModules'.": {
18011801
"category": "Error",
18021802
"code": 5046
18031803
},
1804-
"Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
1804+
"Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
18051805
"category": "Error",
18061806
"code": 5047
18071807
},

Diff for: src/compiler/emitter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
17171717
}
17181718

17191719
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
1720-
if (compilerOptions.separateCompilation) {
1720+
if (compilerOptions.isolatedModules) {
17211721
// do not inline enum values in separate compilation mode
17221722
return false;
17231723
}
@@ -4368,7 +4368,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
43684368

43694369
function shouldEmitEnumDeclaration(node: EnumDeclaration) {
43704370
let isConstEnum = isConst(node);
4371-
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation;
4371+
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules;
43724372
}
43734373

43744374
function emitEnumDeclaration(node: EnumDeclaration) {
@@ -4473,7 +4473,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
44734473
}
44744474

44754475
function shouldEmitModuleDeclaration(node: ModuleDeclaration) {
4476-
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation);
4476+
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules);
44774477
}
44784478

44794479
function isModuleMergedWithES6Class(node: ModuleDeclaration) {
@@ -5682,7 +5682,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
56825682
}
56835683
}
56845684

5685-
if (isExternalModule(node) || compilerOptions.separateCompilation) {
5685+
if (isExternalModule(node) || compilerOptions.isolatedModules) {
56865686
if (languageVersion >= ScriptTarget.ES6) {
56875687
emitES6Module(node, startIndex);
56885688
}

Diff for: src/compiler/program.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -529,21 +529,21 @@ module ts {
529529
}
530530

531531
function verifyCompilerOptions() {
532-
if (options.separateCompilation) {
532+
if (options.isolatedModules) {
533533
if (options.sourceMap) {
534-
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation));
534+
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules));
535535
}
536536

537537
if (options.declaration) {
538-
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation));
538+
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules));
539539
}
540540

541541
if (options.noEmitOnError) {
542-
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation));
542+
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules));
543543
}
544544

545545
if (options.out) {
546-
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation));
546+
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules));
547547
}
548548
}
549549

@@ -580,15 +580,15 @@ module ts {
580580
let languageVersion = options.target || ScriptTarget.ES3;
581581

582582
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
583-
if (options.separateCompilation) {
583+
if (options.isolatedModules) {
584584
if (!options.module && languageVersion < ScriptTarget.ES6) {
585-
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
585+
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
586586
}
587587

588588
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
589589
if (firstNonExternalModuleSourceFile) {
590590
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
591-
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided));
591+
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
592592
}
593593
}
594594
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {

Diff for: src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ module ts {
16761676
target?: ScriptTarget;
16771677
version?: boolean;
16781678
watch?: boolean;
1679-
separateCompilation?: boolean;
1679+
isolatedModules?: boolean;
16801680
emitDecoratorMetadata?: boolean;
16811681
/* @internal */ stripInternal?: boolean;
16821682
[option: string]: string | number | boolean;

Diff for: src/compiler/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ module ts {
14381438
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
14391439
// 1. in-browser single file compilation scenario
14401440
// 2. non .js file
1441-
return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js");
1441+
return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js");
14421442
}
14431443
return false;
14441444
}

Diff for: src/harness/harness.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ module Utils {
4545
export function getExecutionEnvironment() {
4646
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
4747
return ExecutionEnvironment.CScript;
48-
} else if (typeof window !== "undefined") {
48+
} else if (typeof window !== "undefined") {
4949
return ExecutionEnvironment.Browser;
50-
} else {
51-
return ExecutionEnvironment.Node;
50+
} else {
51+
return ExecutionEnvironment.Node;
5252
}
5353
}
5454

@@ -1092,8 +1092,8 @@ module Harness {
10921092
options.preserveConstEnums = setting.value === 'true';
10931093
break;
10941094

1095-
case 'separatecompilation':
1096-
options.separateCompilation = setting.value === 'true';
1095+
case 'isolatedmodules':
1096+
options.isolatedModules = setting.value === 'true';
10971097
break;
10981098

10991099
case 'suppressimplicitanyindexerrors':
@@ -1509,7 +1509,7 @@ module Harness {
15091509
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
15101510
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
15111511
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
1512-
"separatecompilation", "inlinesourcemap", "maproot", "sourceroot",
1512+
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
15131513
"inlinesources", "emitdecoratormetadata"];
15141514

15151515
function extractCompilerSettings(content: string): CompilerSetting[] {

Diff for: src/services/services.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1761,13 +1761,13 @@ module ts {
17611761
* This function will compile source text from 'input' argument using specified compiler options.
17621762
* If not options are provided - it will use a set of default compiler options.
17631763
* Extra compiler options that will unconditionally be used bu this function are:
1764-
* - separateCompilation = true
1764+
* - isolatedModules = true
17651765
* - allowNonTsExtensions = true
17661766
*/
17671767
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
17681768
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
17691769

1770-
options.separateCompilation = true;
1770+
options.isolatedModules = true;
17711771

17721772
// Filename can be non-ts file.
17731773
options.allowNonTsExtensions = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/isolatedModulesAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
2+
3+
4+
==== tests/cases/compiler/isolatedModulesAmbientConstEnum.ts (1 errors) ====
5+
6+
7+
declare const enum E { X = 1}
8+
~
9+
!!! error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
10+
export var y;

0 commit comments

Comments
 (0)