From 1da04ba8f4b3146ae26eafc00e2355586759cdc4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 18 May 2015 21:49:41 -0700 Subject: [PATCH 01/26] Change flag --singleCompilation to --isolatedModules --- src/compiler/checker.ts | 14 +++++++------- src/compiler/commandLineParser.ts | 2 +- .../diagnosticInformationMap.generated.ts | 14 +++++++------- src/compiler/diagnosticMessages.json | 14 +++++++------- src/compiler/emitter.ts | 8 ++++---- src/compiler/program.ts | 16 ++++++++-------- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 2 +- src/harness/harness.ts | 12 ++++++------ src/services/services.ts | 4 ++-- ...eparateCompilationAmbientConstEnum.errors.txt | 4 ++-- .../separateCompilationDeclaration.errors.txt | 4 ++-- .../separateCompilationNoEmitOnError.errors.txt | 4 ++-- ...eparateCompilationNoExternalModule.errors.txt | 4 ++-- .../reference/separateCompilationOut.errors.txt | 8 ++++---- .../separateCompilationPlainFile-AMD.errors.txt | 4 ++-- ...arateCompilationPlainFile-CommonJS.errors.txt | 4 ++-- .../separateCompilationPlainFile-ES6.errors.txt | 4 ++-- ...eparateCompilationPlainFile-System.errors.txt | 4 ++-- .../separateCompilationPlainFile-UMD.errors.txt | 4 ++-- .../separateCompilationSourceMap.errors.txt | 4 ++-- ...parateCompilationUnspecifiedModule.errors.txt | 4 ++-- .../separateCompilationAmbientConstEnum.ts | 2 +- .../compiler/separateCompilationDeclaration.ts | 2 +- tests/cases/compiler/separateCompilationES6.ts | 2 +- .../separateCompilationImportExportElision.ts | 2 +- .../compiler/separateCompilationNoEmitOnError.ts | 2 +- .../separateCompilationNoExternalModule.ts | 2 +- .../separateCompilationNonAmbientConstEnum.ts | 2 +- tests/cases/compiler/separateCompilationOut.ts | 2 +- .../compiler/separateCompilationPlainFile-AMD.ts | 2 +- .../separateCompilationPlainFile-CommonJS.ts | 2 +- .../compiler/separateCompilationPlainFile-ES6.ts | 2 +- .../separateCompilationPlainFile-System.ts | 2 +- .../compiler/separateCompilationPlainFile-UMD.ts | 2 +- .../compiler/separateCompilationSourceMap.ts | 2 +- .../separateCompilationSpecifiedModule.ts | 2 +- .../separateCompilationUnspecifiedModule.ts | 2 +- .../separateCompilationWithDeclarationFile.ts | 2 +- tests/cases/compiler/systemModule10.ts | 2 +- tests/cases/compiler/systemModule10_ES5.ts | 2 +- tests/cases/compiler/systemModule11.ts | 2 +- tests/cases/compiler/systemModule9.ts | 2 +- 43 files changed, 91 insertions(+), 91 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a4ba23ca2a..d956ac189a5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -732,7 +732,7 @@ module ts { let target = resolveAlias(symbol); if (target) { let markAlias = - (target === unknownSymbol && compilerOptions.separateCompilation) || + (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & SymbolFlags.Value) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { @@ -8889,7 +8889,7 @@ module ts { // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let type = getTypeFromTypeNode(node); - let shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; + let shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (TypeFlags.Intrinsic | TypeFlags.NumberLike | TypeFlags.StringLike))) { return; } @@ -10054,7 +10054,7 @@ module ts { } } - if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { + if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { // Check that base type can be evaluated as expression checkExpressionOrQualifiedName(baseTypeNode.expression); } @@ -10470,8 +10470,8 @@ module ts { computeEnumMemberValues(node); let enumIsConst = isConst(node); - if (compilerOptions.separateCompilation && enumIsConst && isInAmbientContext(node)) { - error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided); + if (compilerOptions.isolatedModules && enumIsConst && isInAmbientContext(node)) { + error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } // Spec 2014 - Section 9.3: @@ -10561,7 +10561,7 @@ module ts { if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node) - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { + && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { let firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -11661,7 +11661,7 @@ module ts { function isAliasResolvedToValue(symbol: Symbol): boolean { let target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.separateCompilation) { + if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6a055aebf6a..64784590024 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -142,7 +142,7 @@ module ts { paramType: Diagnostics.LOCATION, }, { - name: "separateCompilation", + name: "isolatedModules", type: "boolean", }, { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 1f8edf8fee3..8dd6ea6dc55 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -165,8 +165,8 @@ module ts { 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." }, Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." }, 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." }, - Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, - 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." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + 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." }, 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." }, 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" }, 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 { 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'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, 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." }, - Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." }, - Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." }, - Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, - Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, - 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." }, + Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, + Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, + Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, + Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, + 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." }, Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 42eae83e269..416936e741b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -647,11 +647,11 @@ "category": "Error", "code": 1207 }, - "Cannot compile namespaces when the '--separateCompilation' flag is provided.": { + "Cannot compile namespaces when the '--isolatedModules' flag is provided.": { "category": "Error", "code": 1208 }, - "Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": { + "Ambient const enums are not allowed when the '--isolatedModules' flag is provided.": { "category": "Error", "code": 1209 }, @@ -1785,23 +1785,23 @@ "category": "Error", "code": 5042 }, - "Option 'sourceMap' cannot be specified with option 'separateCompilation'.": { + "Option 'sourceMap' cannot be specified with option 'isolatedModules'.": { "category": "Error", "code": 5043 }, - "Option 'declaration' cannot be specified with option 'separateCompilation'.": { + "Option 'declaration' cannot be specified with option 'isolatedModules'.": { "category": "Error", "code": 5044 }, - "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": { + "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": { "category": "Error", "code": 5045 }, - "Option 'out' cannot be specified with option 'separateCompilation'.": { + "Option 'out' cannot be specified with option 'isolatedModules'.": { "category": "Error", "code": 5046 }, - "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { + "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { "category": "Error", "code": 5047 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6d5146a6801..e1e6cba2175 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1714,7 +1714,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { - if (compilerOptions.separateCompilation) { + if (compilerOptions.isolatedModules) { // do not inline enum values in separate compilation mode return false; } @@ -4364,7 +4364,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function shouldEmitEnumDeclaration(node: EnumDeclaration) { let isConstEnum = isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } function emitEnumDeclaration(node: EnumDeclaration) { @@ -4456,7 +4456,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function shouldEmitModuleDeclaration(node: ModuleDeclaration) { - return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node: ModuleDeclaration) { @@ -5631,7 +5631,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } - if (isExternalModule(node) || compilerOptions.separateCompilation) { + if (isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= ScriptTarget.ES6) { emitES6Module(node, startIndex); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3bd4bdc7ac0..bf554384241 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -529,21 +529,21 @@ module ts { } function verifyCompilerOptions() { - if (options.separateCompilation) { + if (options.isolatedModules) { if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); } if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } if (options.noEmitOnError) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); } if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); } } @@ -580,15 +580,15 @@ module ts { let languageVersion = options.target || ScriptTarget.ES3; let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); - if (options.separateCompilation) { + if (options.isolatedModules) { if (!options.module && languageVersion < ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (firstNonExternalModuleSourceFile) { let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86e680ca8b0..a6fa89846bb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1676,7 +1676,7 @@ module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; - separateCompilation?: boolean; + isolatedModules?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; [option: string]: string | number | boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0bb0065d1b0..3ded0a7cfd9 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1438,7 +1438,7 @@ module ts { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { // 1. in-browser single file compilation scenario // 2. non .js file - return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js"); + return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js"); } return false; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9ed515eb5b6..63eff36b30a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -45,10 +45,10 @@ module Utils { export function getExecutionEnvironment() { if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return ExecutionEnvironment.CScript; - } else if (typeof window !== "undefined") { + } else if (typeof window !== "undefined") { return ExecutionEnvironment.Browser; - } else { - return ExecutionEnvironment.Node; + } else { + return ExecutionEnvironment.Node; } } @@ -1092,8 +1092,8 @@ module Harness { options.preserveConstEnums = setting.value === 'true'; break; - case 'separatecompilation': - options.separateCompilation = setting.value === 'true'; + case 'isolatedmodules': + options.isolatedModules = setting.value === 'true'; break; case 'suppressimplicitanyindexerrors': @@ -1509,7 +1509,7 @@ module Harness { "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "separatecompilation", "inlinesourcemap", "maproot", "sourceroot", + "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", "inlinesources", "emitdecoratormetadata"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/src/services/services.ts b/src/services/services.ts index bec00b9a66a..c805b0c7eea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1760,13 +1760,13 @@ module ts { * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. * Extra compiler options that will unconditionally be used bu this function are: - * - separateCompilation = true + * - isolatedModules = true * - allowNonTsExtensions = true */ export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string { let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions(); - options.separateCompilation = true; + options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; diff --git a/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt b/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt index 6ea2e445e29..ea55115e957 100644 --- a/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt +++ b/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/separateCompilationAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationAmbientConstEnum.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/separateCompilationAmbientConstEnum.ts(3,20): error TS1209: declare const enum E { X = 1} ~ -!!! error TS1209: Ambient const enums are not allowed when the '--separateCompilation' flag is provided. +!!! error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. export var y; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationDeclaration.errors.txt b/tests/baselines/reference/separateCompilationDeclaration.errors.txt index 8951184584c..107d917c751 100644 --- a/tests/baselines/reference/separateCompilationDeclaration.errors.txt +++ b/tests/baselines/reference/separateCompilationDeclaration.errors.txt @@ -1,7 +1,7 @@ -error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'. +error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. -!!! error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'. +!!! error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/separateCompilationDeclaration.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt b/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt index 61d4f2d6d9e..ddb471cef49 100644 --- a/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt +++ b/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt @@ -1,7 +1,7 @@ -error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'. +error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. -!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'. +!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/separateCompilationNoEmitOnError.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt b/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt index 71d7da73a80..7c242e90f12 100644 --- a/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt +++ b/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/separateCompilationNoExternalModule.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationNoExternalModule.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationNoExternalModule.ts (1 errors) ==== var x; ~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. \ No newline at end of file +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationOut.errors.txt b/tests/baselines/reference/separateCompilationOut.errors.txt index 9017809901f..8234ba94585 100644 --- a/tests/baselines/reference/separateCompilationOut.errors.txt +++ b/tests/baselines/reference/separateCompilationOut.errors.txt @@ -1,12 +1,12 @@ -error TS5046: Option 'out' cannot be specified with option 'separateCompilation'. -tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. -!!! error TS5046: Option 'out' cannot be specified with option 'separateCompilation'. +!!! error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/file1.ts (0 errors) ==== export var x; ==== tests/cases/compiler/file2.ts (1 errors) ==== var y; ~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. \ No newline at end of file +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt index 6b80da30d33..329299f5130 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt +++ b/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/separateCompilationPlainFile-AMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationPlainFile-AMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationPlainFile-AMD.ts (1 errors) ==== declare function run(a: number): void; ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. run(1); \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt index 48a23a39653..e72a4a76b71 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt +++ b/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts (1 errors) ==== declare function run(a: number): void; ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. run(1); \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt index b0b059c73bd..602d41ce948 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt +++ b/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/separateCompilationPlainFile-ES6.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationPlainFile-ES6.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationPlainFile-ES6.ts (1 errors) ==== declare function run(a: number): void; ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. run(1); \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt index c3161c57275..a6d14edd61a 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt +++ b/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/separateCompilationPlainFile-System.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationPlainFile-System.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationPlainFile-System.ts (1 errors) ==== declare function run(a: number): void; ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. run(1); \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt index 6a0fb1ac8df..d15098a96c1 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt +++ b/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/separateCompilationPlainFile-UMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +tests/cases/compiler/separateCompilationPlainFile-UMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. ==== tests/cases/compiler/separateCompilationPlainFile-UMD.ts (1 errors) ==== declare function run(a: number): void; ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--separateCompilation' flag is provided. +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. run(1); \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSourceMap.errors.txt b/tests/baselines/reference/separateCompilationSourceMap.errors.txt index 5274ef3921e..56fc5b5cb85 100644 --- a/tests/baselines/reference/separateCompilationSourceMap.errors.txt +++ b/tests/baselines/reference/separateCompilationSourceMap.errors.txt @@ -1,7 +1,7 @@ -error TS5043: Option 'sourceMap' cannot be specified with option 'separateCompilation'. +error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'. -!!! error TS5043: Option 'sourceMap' cannot be specified with option 'separateCompilation'. +!!! error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/separateCompilationSourceMap.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt b/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt index ab0fd7ffe9d..0691be32c7c 100644 --- a/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt +++ b/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt @@ -1,6 +1,6 @@ -error TS5047: Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher. +error TS5047: Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher. -!!! error TS5047: Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher. +!!! error TS5047: Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher. ==== tests/cases/compiler/separateCompilationUnspecifiedModule.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationAmbientConstEnum.ts b/tests/cases/compiler/separateCompilationAmbientConstEnum.ts index aaccfaaf02c..59fcdcd1fe4 100644 --- a/tests/cases/compiler/separateCompilationAmbientConstEnum.ts +++ b/tests/cases/compiler/separateCompilationAmbientConstEnum.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es6 // @filename: file1.ts diff --git a/tests/cases/compiler/separateCompilationDeclaration.ts b/tests/cases/compiler/separateCompilationDeclaration.ts index 11003a19193..3d5e7db9b4f 100644 --- a/tests/cases/compiler/separateCompilationDeclaration.ts +++ b/tests/cases/compiler/separateCompilationDeclaration.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @declaration: true // @target: es6 diff --git a/tests/cases/compiler/separateCompilationES6.ts b/tests/cases/compiler/separateCompilationES6.ts index a2ac8c8d94e..12e8d8adb7f 100644 --- a/tests/cases/compiler/separateCompilationES6.ts +++ b/tests/cases/compiler/separateCompilationES6.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es6 // @filename: file1.ts export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationImportExportElision.ts b/tests/cases/compiler/separateCompilationImportExportElision.ts index d7af74a1a69..e50a0f8eb88 100644 --- a/tests/cases/compiler/separateCompilationImportExportElision.ts +++ b/tests/cases/compiler/separateCompilationImportExportElision.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es5 // @module: commonjs diff --git a/tests/cases/compiler/separateCompilationNoEmitOnError.ts b/tests/cases/compiler/separateCompilationNoEmitOnError.ts index fe0f59199f6..ce3085dbc3b 100644 --- a/tests/cases/compiler/separateCompilationNoEmitOnError.ts +++ b/tests/cases/compiler/separateCompilationNoEmitOnError.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @noEmitOnError:true // @target: es6 diff --git a/tests/cases/compiler/separateCompilationNoExternalModule.ts b/tests/cases/compiler/separateCompilationNoExternalModule.ts index e66ef27c005..37b61fcbc1a 100644 --- a/tests/cases/compiler/separateCompilationNoExternalModule.ts +++ b/tests/cases/compiler/separateCompilationNoExternalModule.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es6 // @filename: file1.ts diff --git a/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts b/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts index 5f3054238d9..d5aae618d8f 100644 --- a/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts +++ b/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es6 // @filename: file1.ts diff --git a/tests/cases/compiler/separateCompilationOut.ts b/tests/cases/compiler/separateCompilationOut.ts index 6c0a95f8ae5..c977a4b54da 100644 --- a/tests/cases/compiler/separateCompilationOut.ts +++ b/tests/cases/compiler/separateCompilationOut.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @out:all.js // @target: es6 diff --git a/tests/cases/compiler/separateCompilationPlainFile-AMD.ts b/tests/cases/compiler/separateCompilationPlainFile-AMD.ts index a1010ce3e8c..d28aea86250 100644 --- a/tests/cases/compiler/separateCompilationPlainFile-AMD.ts +++ b/tests/cases/compiler/separateCompilationPlainFile-AMD.ts @@ -1,6 +1,6 @@ // @target: es5 // @module: amd -// @separateCompilation: true +// @isolatedModules: true declare function run(a: number): void; run(1); diff --git a/tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts b/tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts index 532d97f09eb..6d07f10c4d0 100644 --- a/tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts +++ b/tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts @@ -1,6 +1,6 @@ // @target: es5 // @module: commonjs -// @separateCompilation: true +// @isolatedModules: true declare function run(a: number): void; run(1); diff --git a/tests/cases/compiler/separateCompilationPlainFile-ES6.ts b/tests/cases/compiler/separateCompilationPlainFile-ES6.ts index 20d4e8d79a2..051aa548149 100644 --- a/tests/cases/compiler/separateCompilationPlainFile-ES6.ts +++ b/tests/cases/compiler/separateCompilationPlainFile-ES6.ts @@ -1,5 +1,5 @@ // @target: es6 -// @separateCompilation: true +// @isolatedModules: true declare function run(a: number): void; run(1); diff --git a/tests/cases/compiler/separateCompilationPlainFile-System.ts b/tests/cases/compiler/separateCompilationPlainFile-System.ts index 69065718254..e16720596d9 100644 --- a/tests/cases/compiler/separateCompilationPlainFile-System.ts +++ b/tests/cases/compiler/separateCompilationPlainFile-System.ts @@ -1,6 +1,6 @@ // @target: es5 // @module: system -// @separateCompilation: true +// @isolatedModules: true declare function run(a: number): void; run(1); diff --git a/tests/cases/compiler/separateCompilationPlainFile-UMD.ts b/tests/cases/compiler/separateCompilationPlainFile-UMD.ts index 4ab45686c90..d452bbff96b 100644 --- a/tests/cases/compiler/separateCompilationPlainFile-UMD.ts +++ b/tests/cases/compiler/separateCompilationPlainFile-UMD.ts @@ -1,6 +1,6 @@ // @target: es5 // @module: umd -// @separateCompilation: true +// @isolatedModules: true declare function run(a: number): void; run(1); diff --git a/tests/cases/compiler/separateCompilationSourceMap.ts b/tests/cases/compiler/separateCompilationSourceMap.ts index 84c6290caf5..31dd4d9f0cf 100644 --- a/tests/cases/compiler/separateCompilationSourceMap.ts +++ b/tests/cases/compiler/separateCompilationSourceMap.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @sourceMap:true // @target: es6 diff --git a/tests/cases/compiler/separateCompilationSpecifiedModule.ts b/tests/cases/compiler/separateCompilationSpecifiedModule.ts index 6ba3a0d3bf4..0e72e6480b6 100644 --- a/tests/cases/compiler/separateCompilationSpecifiedModule.ts +++ b/tests/cases/compiler/separateCompilationSpecifiedModule.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @module: commonjs // @filename: file1.ts export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationUnspecifiedModule.ts b/tests/cases/compiler/separateCompilationUnspecifiedModule.ts index 38a3fd82868..2435f22e952 100644 --- a/tests/cases/compiler/separateCompilationUnspecifiedModule.ts +++ b/tests/cases/compiler/separateCompilationUnspecifiedModule.ts @@ -1,3 +1,3 @@ -// @separateCompilation: true +// @isolatedModules: true // @filename: file1.ts export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationWithDeclarationFile.ts b/tests/cases/compiler/separateCompilationWithDeclarationFile.ts index 121db1702a5..01e96b4ec2a 100644 --- a/tests/cases/compiler/separateCompilationWithDeclarationFile.ts +++ b/tests/cases/compiler/separateCompilationWithDeclarationFile.ts @@ -1,4 +1,4 @@ -// @separateCompilation: true +// @isolatedModules: true // @target: es6 // @filename: file1.d.ts diff --git a/tests/cases/compiler/systemModule10.ts b/tests/cases/compiler/systemModule10.ts index 49e99fb1c63..41aea2c8244 100644 --- a/tests/cases/compiler/systemModule10.ts +++ b/tests/cases/compiler/systemModule10.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true import n, {x} from 'file1' import n2 = require('file2'); diff --git a/tests/cases/compiler/systemModule10_ES5.ts b/tests/cases/compiler/systemModule10_ES5.ts index 6468e4125d1..5e51b9152f8 100644 --- a/tests/cases/compiler/systemModule10_ES5.ts +++ b/tests/cases/compiler/systemModule10_ES5.ts @@ -1,6 +1,6 @@ // @target: es5 // @module: system -// @separateCompilation: true +// @isolatedModules: true import n, {x} from 'file1' import n2 = require('file2'); diff --git a/tests/cases/compiler/systemModule11.ts b/tests/cases/compiler/systemModule11.ts index 28e88688f87..15784b2f8c4 100644 --- a/tests/cases/compiler/systemModule11.ts +++ b/tests/cases/compiler/systemModule11.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true // set of tests cases that checks generation of local storage for exported names diff --git a/tests/cases/compiler/systemModule9.ts b/tests/cases/compiler/systemModule9.ts index c6ff742b1bf..f124a1112c3 100644 --- a/tests/cases/compiler/systemModule9.ts +++ b/tests/cases/compiler/systemModule9.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true import * as ns from 'file1'; import {a, b as c} from 'file2'; From 6057a918ecacd0cd62eaa389144a0839c82e4f2e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 18 May 2015 22:21:29 -0700 Subject: [PATCH 02/26] rename tests --- ...isolatedModulesAmbientConstEnum.errors.txt | 10 +++++++ .../isolatedModulesAmbientConstEnum.js | 8 ++++++ ... => isolatedModulesDeclaration.errors.txt} | 2 +- .../reference/isolatedModulesDeclaration.js | 10 +++++++ .../baselines/reference/isolatedModulesES6.js | 5 ++++ .../reference/isolatedModulesES6.symbols | 4 +++ .../reference/isolatedModulesES6.types | 4 +++ ...latedModulesImportExportElision.errors.txt | 28 +++++++++++++++++++ ... => isolatedModulesImportExportElision.js} | 4 +-- ...> isolatedModulesNoEmitOnError.errors.txt} | 2 +- ...isolatedModulesNoExternalModule.errors.txt | 8 ++++++ .../isolatedModulesNoExternalModule.js | 6 ++++ ... => isolatedModulesNonAmbientConstEnum.js} | 4 +-- ...isolatedModulesNonAmbientConstEnum.symbols | 15 ++++++++++ ... isolatedModulesNonAmbientConstEnum.types} | 2 +- ...rors.txt => isolatedModulesOut.errors.txt} | 0 ...ompilationOut.js => isolatedModulesOut.js} | 2 +- .../isolatedModulesPlainFile-AMD.errors.txt | 10 +++++++ ...AMD.js => isolatedModulesPlainFile-AMD.js} | 4 +-- ...olatedModulesPlainFile-CommonJS.errors.txt | 10 +++++++ .../isolatedModulesPlainFile-CommonJS.js | 8 ++++++ .../isolatedModulesPlainFile-ES6.errors.txt | 10 +++++++ .../reference/isolatedModulesPlainFile-ES6.js | 8 ++++++ ...isolatedModulesPlainFile-System.errors.txt | 10 +++++++ ....js => isolatedModulesPlainFile-System.js} | 4 +-- .../isolatedModulesPlainFile-UMD.errors.txt | 10 +++++++ ...UMD.js => isolatedModulesPlainFile-UMD.js} | 4 +-- ...xt => isolatedModulesSourceMap.errors.txt} | 2 +- .../reference/isolatedModulesSourceMap.js | 7 +++++ .../reference/isolatedModulesSourceMap.js.map | 2 ++ ...=> isolatedModulesSourceMap.sourcemap.txt} | 14 +++++----- .../isolatedModulesSpecifiedModule.js | 5 ++++ .../isolatedModulesSpecifiedModule.symbols | 4 +++ .../isolatedModulesSpecifiedModule.types | 4 +++ ...olatedModulesUnspecifiedModule.errors.txt} | 2 +- .../isolatedModulesUnspecifiedModule.js | 5 ++++ ... => isolatedModulesWithDeclarationFile.js} | 2 +- ...solatedModulesWithDeclarationFile.symbols} | 0 ... isolatedModulesWithDeclarationFile.types} | 0 ...rateCompilationAmbientConstEnum.errors.txt | 10 ------- .../separateCompilationAmbientConstEnum.js | 8 ------ .../separateCompilationDeclaration.js | 10 ------- .../reference/separateCompilationES6.js | 5 ---- .../reference/separateCompilationES6.symbols | 4 --- .../reference/separateCompilationES6.types | 4 --- ...eCompilationImportExportElision.errors.txt | 28 ------------------- ...rateCompilationNoExternalModule.errors.txt | 8 ------ .../separateCompilationNoExternalModule.js | 6 ---- ...rateCompilationNonAmbientConstEnum.symbols | 15 ---------- ...eparateCompilationPlainFile-AMD.errors.txt | 10 ------- ...teCompilationPlainFile-CommonJS.errors.txt | 10 ------- .../separateCompilationPlainFile-CommonJS.js | 8 ------ ...eparateCompilationPlainFile-ES6.errors.txt | 10 ------- .../separateCompilationPlainFile-ES6.js | 8 ------ ...rateCompilationPlainFile-System.errors.txt | 10 ------- ...eparateCompilationPlainFile-UMD.errors.txt | 10 ------- .../reference/separateCompilationSourceMap.js | 7 ----- .../separateCompilationSourceMap.js.map | 2 -- .../separateCompilationSpecifiedModule.js | 5 ---- ...separateCompilationSpecifiedModule.symbols | 4 --- .../separateCompilationSpecifiedModule.types | 4 --- .../separateCompilationUnspecifiedModule.js | 5 ---- ....ts => isolatedModulesAmbientConstEnum.ts} | 0 ...ation.ts => isolatedModulesDeclaration.ts} | 0 ...ompilationES6.ts => isolatedModulesES6.ts} | 0 ... => isolatedModulesImportExportElision.ts} | 0 ...ror.ts => isolatedModulesNoEmitOnError.ts} | 0 ....ts => isolatedModulesNoExternalModule.ts} | 0 ... => isolatedModulesNonAmbientConstEnum.ts} | 0 ...ompilationOut.ts => isolatedModulesOut.ts} | 0 ...AMD.ts => isolatedModulesPlainFile-AMD.ts} | 0 ...s => isolatedModulesPlainFile-CommonJS.ts} | 0 ...ES6.ts => isolatedModulesPlainFile-ES6.ts} | 0 ....ts => isolatedModulesPlainFile-System.ts} | 0 ...UMD.ts => isolatedModulesPlainFile-UMD.ts} | 0 ...urceMap.ts => isolatedModulesSourceMap.ts} | 0 ...e.ts => isolatedModulesSpecifiedModule.ts} | 0 ...ts => isolatedModulesUnspecifiedModule.ts} | 0 ... => isolatedModulesWithDeclarationFile.ts} | 0 79 files changed, 215 insertions(+), 215 deletions(-) create mode 100644 tests/baselines/reference/isolatedModulesAmbientConstEnum.errors.txt create mode 100644 tests/baselines/reference/isolatedModulesAmbientConstEnum.js rename tests/baselines/reference/{separateCompilationDeclaration.errors.txt => isolatedModulesDeclaration.errors.txt} (64%) create mode 100644 tests/baselines/reference/isolatedModulesDeclaration.js create mode 100644 tests/baselines/reference/isolatedModulesES6.js create mode 100644 tests/baselines/reference/isolatedModulesES6.symbols create mode 100644 tests/baselines/reference/isolatedModulesES6.types create mode 100644 tests/baselines/reference/isolatedModulesImportExportElision.errors.txt rename tests/baselines/reference/{separateCompilationImportExportElision.js => isolatedModulesImportExportElision.js} (86%) rename tests/baselines/reference/{separateCompilationNoEmitOnError.errors.txt => isolatedModulesNoEmitOnError.errors.txt} (64%) create mode 100644 tests/baselines/reference/isolatedModulesNoExternalModule.errors.txt create mode 100644 tests/baselines/reference/isolatedModulesNoExternalModule.js rename tests/baselines/reference/{separateCompilationNonAmbientConstEnum.js => isolatedModulesNonAmbientConstEnum.js} (58%) create mode 100644 tests/baselines/reference/isolatedModulesNonAmbientConstEnum.symbols rename tests/baselines/reference/{separateCompilationNonAmbientConstEnum.types => isolatedModulesNonAmbientConstEnum.types} (60%) rename tests/baselines/reference/{separateCompilationOut.errors.txt => isolatedModulesOut.errors.txt} (100%) rename tests/baselines/reference/{separateCompilationOut.js => isolatedModulesOut.js} (60%) create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-AMD.errors.txt rename tests/baselines/reference/{separateCompilationPlainFile-AMD.js => isolatedModulesPlainFile-AMD.js} (57%) create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-CommonJS.errors.txt create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-ES6.errors.txt create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-ES6.js create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-System.errors.txt rename tests/baselines/reference/{separateCompilationPlainFile-System.js => isolatedModulesPlainFile-System.js} (65%) create mode 100644 tests/baselines/reference/isolatedModulesPlainFile-UMD.errors.txt rename tests/baselines/reference/{separateCompilationPlainFile-UMD.js => isolatedModulesPlainFile-UMD.js} (80%) rename tests/baselines/reference/{separateCompilationSourceMap.errors.txt => isolatedModulesSourceMap.errors.txt} (64%) create mode 100644 tests/baselines/reference/isolatedModulesSourceMap.js create mode 100644 tests/baselines/reference/isolatedModulesSourceMap.js.map rename tests/baselines/reference/{separateCompilationSourceMap.sourcemap.txt => isolatedModulesSourceMap.sourcemap.txt} (61%) create mode 100644 tests/baselines/reference/isolatedModulesSpecifiedModule.js create mode 100644 tests/baselines/reference/isolatedModulesSpecifiedModule.symbols create mode 100644 tests/baselines/reference/isolatedModulesSpecifiedModule.types rename tests/baselines/reference/{separateCompilationUnspecifiedModule.errors.txt => isolatedModulesUnspecifiedModule.errors.txt} (72%) create mode 100644 tests/baselines/reference/isolatedModulesUnspecifiedModule.js rename tests/baselines/reference/{separateCompilationWithDeclarationFile.js => isolatedModulesWithDeclarationFile.js} (57%) rename tests/baselines/reference/{separateCompilationWithDeclarationFile.symbols => isolatedModulesWithDeclarationFile.symbols} (100%) rename tests/baselines/reference/{separateCompilationWithDeclarationFile.types => isolatedModulesWithDeclarationFile.types} (100%) delete mode 100644 tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationAmbientConstEnum.js delete mode 100644 tests/baselines/reference/separateCompilationDeclaration.js delete mode 100644 tests/baselines/reference/separateCompilationES6.js delete mode 100644 tests/baselines/reference/separateCompilationES6.symbols delete mode 100644 tests/baselines/reference/separateCompilationES6.types delete mode 100644 tests/baselines/reference/separateCompilationImportExportElision.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationNoExternalModule.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationNoExternalModule.js delete mode 100644 tests/baselines/reference/separateCompilationNonAmbientConstEnum.symbols delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-CommonJS.js delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-ES6.js delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-System.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt delete mode 100644 tests/baselines/reference/separateCompilationSourceMap.js delete mode 100644 tests/baselines/reference/separateCompilationSourceMap.js.map delete mode 100644 tests/baselines/reference/separateCompilationSpecifiedModule.js delete mode 100644 tests/baselines/reference/separateCompilationSpecifiedModule.symbols delete mode 100644 tests/baselines/reference/separateCompilationSpecifiedModule.types delete mode 100644 tests/baselines/reference/separateCompilationUnspecifiedModule.js rename tests/cases/compiler/{separateCompilationAmbientConstEnum.ts => isolatedModulesAmbientConstEnum.ts} (100%) rename tests/cases/compiler/{separateCompilationDeclaration.ts => isolatedModulesDeclaration.ts} (100%) rename tests/cases/compiler/{separateCompilationES6.ts => isolatedModulesES6.ts} (100%) rename tests/cases/compiler/{separateCompilationImportExportElision.ts => isolatedModulesImportExportElision.ts} (100%) rename tests/cases/compiler/{separateCompilationNoEmitOnError.ts => isolatedModulesNoEmitOnError.ts} (100%) rename tests/cases/compiler/{separateCompilationNoExternalModule.ts => isolatedModulesNoExternalModule.ts} (100%) rename tests/cases/compiler/{separateCompilationNonAmbientConstEnum.ts => isolatedModulesNonAmbientConstEnum.ts} (100%) rename tests/cases/compiler/{separateCompilationOut.ts => isolatedModulesOut.ts} (100%) rename tests/cases/compiler/{separateCompilationPlainFile-AMD.ts => isolatedModulesPlainFile-AMD.ts} (100%) rename tests/cases/compiler/{separateCompilationPlainFile-CommonJS.ts => isolatedModulesPlainFile-CommonJS.ts} (100%) rename tests/cases/compiler/{separateCompilationPlainFile-ES6.ts => isolatedModulesPlainFile-ES6.ts} (100%) rename tests/cases/compiler/{separateCompilationPlainFile-System.ts => isolatedModulesPlainFile-System.ts} (100%) rename tests/cases/compiler/{separateCompilationPlainFile-UMD.ts => isolatedModulesPlainFile-UMD.ts} (100%) rename tests/cases/compiler/{separateCompilationSourceMap.ts => isolatedModulesSourceMap.ts} (100%) rename tests/cases/compiler/{separateCompilationSpecifiedModule.ts => isolatedModulesSpecifiedModule.ts} (100%) rename tests/cases/compiler/{separateCompilationUnspecifiedModule.ts => isolatedModulesUnspecifiedModule.ts} (100%) rename tests/cases/compiler/{separateCompilationWithDeclarationFile.ts => isolatedModulesWithDeclarationFile.ts} (100%) diff --git a/tests/baselines/reference/isolatedModulesAmbientConstEnum.errors.txt b/tests/baselines/reference/isolatedModulesAmbientConstEnum.errors.txt new file mode 100644 index 00000000000..bb8a5202bc5 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesAmbientConstEnum.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesAmbientConstEnum.ts (1 errors) ==== + + + declare const enum E { X = 1} + ~ +!!! error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. + export var y; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesAmbientConstEnum.js b/tests/baselines/reference/isolatedModulesAmbientConstEnum.js new file mode 100644 index 00000000000..7742122b687 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesAmbientConstEnum.js @@ -0,0 +1,8 @@ +//// [isolatedModulesAmbientConstEnum.ts] + + +declare const enum E { X = 1} +export var y; + +//// [isolatedModulesAmbientConstEnum.js] +export var y; diff --git a/tests/baselines/reference/separateCompilationDeclaration.errors.txt b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt similarity index 64% rename from tests/baselines/reference/separateCompilationDeclaration.errors.txt rename to tests/baselines/reference/isolatedModulesDeclaration.errors.txt index 107d917c751..de5cb97586c 100644 --- a/tests/baselines/reference/separateCompilationDeclaration.errors.txt +++ b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt @@ -2,6 +2,6 @@ error TS5044: Option 'declaration' cannot be specified with option 'isolatedModu !!! error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. -==== tests/cases/compiler/separateCompilationDeclaration.ts (0 errors) ==== +==== tests/cases/compiler/isolatedModulesDeclaration.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesDeclaration.js b/tests/baselines/reference/isolatedModulesDeclaration.js new file mode 100644 index 00000000000..12e6f23f92e --- /dev/null +++ b/tests/baselines/reference/isolatedModulesDeclaration.js @@ -0,0 +1,10 @@ +//// [isolatedModulesDeclaration.ts] + +export var x; + +//// [isolatedModulesDeclaration.js] +export var x; + + +//// [isolatedModulesDeclaration.d.ts] +export declare var x: any; diff --git a/tests/baselines/reference/isolatedModulesES6.js b/tests/baselines/reference/isolatedModulesES6.js new file mode 100644 index 00000000000..eb2ee3ee33a --- /dev/null +++ b/tests/baselines/reference/isolatedModulesES6.js @@ -0,0 +1,5 @@ +//// [isolatedModulesES6.ts] +export var x; + +//// [isolatedModulesES6.js] +export var x; diff --git a/tests/baselines/reference/isolatedModulesES6.symbols b/tests/baselines/reference/isolatedModulesES6.symbols new file mode 100644 index 00000000000..c705cbc5af8 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesES6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/isolatedModulesES6.ts === +export var x; +>x : Symbol(x, Decl(isolatedModulesES6.ts, 0, 10)) + diff --git a/tests/baselines/reference/isolatedModulesES6.types b/tests/baselines/reference/isolatedModulesES6.types new file mode 100644 index 00000000000..898b9715ca4 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesES6.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/isolatedModulesES6.ts === +export var x; +>x : any + diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.errors.txt b/tests/baselines/reference/isolatedModulesImportExportElision.errors.txt new file mode 100644 index 00000000000..8c6881a9bc1 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesImportExportElision.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/isolatedModulesImportExportElision.ts(2,17): error TS2307: Cannot find module 'module'. +tests/cases/compiler/isolatedModulesImportExportElision.ts(3,18): error TS2307: Cannot find module 'module'. +tests/cases/compiler/isolatedModulesImportExportElision.ts(4,21): error TS2307: Cannot find module 'module'. +tests/cases/compiler/isolatedModulesImportExportElision.ts(12,18): error TS2307: Cannot find module 'module'. + + +==== tests/cases/compiler/isolatedModulesImportExportElision.ts (4 errors) ==== + + import {c} from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find module 'module'. + import {c2} from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find module 'module'. + import * as ns from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find module 'module'. + + class C extends c2.C { + } + + let x = new c(); + let y = ns.value; + + export {c1} from "module"; + ~~~~~~~~ +!!! error TS2307: Cannot find module 'module'. + export var z = x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js similarity index 86% rename from tests/baselines/reference/separateCompilationImportExportElision.js rename to tests/baselines/reference/isolatedModulesImportExportElision.js index cfa57980249..ca3eee0ac2b 100644 --- a/tests/baselines/reference/separateCompilationImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -1,4 +1,4 @@ -//// [separateCompilationImportExportElision.ts] +//// [isolatedModulesImportExportElision.ts] import {c} from "module" import {c2} from "module" @@ -13,7 +13,7 @@ let y = ns.value; export {c1} from "module"; export var z = x; -//// [separateCompilationImportExportElision.js] +//// [isolatedModulesImportExportElision.js] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } diff --git a/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt similarity index 64% rename from tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt rename to tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt index ddb471cef49..68b2747cf6b 100644 --- a/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt +++ b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt @@ -2,6 +2,6 @@ error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedMo !!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. -==== tests/cases/compiler/separateCompilationNoEmitOnError.ts (0 errors) ==== +==== tests/cases/compiler/isolatedModulesNoEmitOnError.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesNoExternalModule.errors.txt b/tests/baselines/reference/isolatedModulesNoExternalModule.errors.txt new file mode 100644 index 00000000000..d00520a0618 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesNoExternalModule.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/isolatedModulesNoExternalModule.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesNoExternalModule.ts (1 errors) ==== + + var x; + ~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesNoExternalModule.js b/tests/baselines/reference/isolatedModulesNoExternalModule.js new file mode 100644 index 00000000000..dd5d23a538c --- /dev/null +++ b/tests/baselines/reference/isolatedModulesNoExternalModule.js @@ -0,0 +1,6 @@ +//// [isolatedModulesNoExternalModule.ts] + +var x; + +//// [isolatedModulesNoExternalModule.js] +var x; diff --git a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.js b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.js similarity index 58% rename from tests/baselines/reference/separateCompilationNonAmbientConstEnum.js rename to tests/baselines/reference/isolatedModulesNonAmbientConstEnum.js index 74096adca1f..efdba17dc93 100644 --- a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.js +++ b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.js @@ -1,10 +1,10 @@ -//// [separateCompilationNonAmbientConstEnum.ts] +//// [isolatedModulesNonAmbientConstEnum.ts] const enum E { X = 100 }; var e = E.X; export var x; -//// [separateCompilationNonAmbientConstEnum.js] +//// [isolatedModulesNonAmbientConstEnum.js] var E; (function (E) { E[E["X"] = 100] = "X"; diff --git a/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.symbols b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.symbols new file mode 100644 index 00000000000..5e30fd0b2ff --- /dev/null +++ b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/isolatedModulesNonAmbientConstEnum.ts === + +const enum E { X = 100 }; +>E : Symbol(E, Decl(isolatedModulesNonAmbientConstEnum.ts, 0, 0)) +>X : Symbol(E.X, Decl(isolatedModulesNonAmbientConstEnum.ts, 1, 14)) + +var e = E.X; +>e : Symbol(e, Decl(isolatedModulesNonAmbientConstEnum.ts, 2, 3)) +>E.X : Symbol(E.X, Decl(isolatedModulesNonAmbientConstEnum.ts, 1, 14)) +>E : Symbol(E, Decl(isolatedModulesNonAmbientConstEnum.ts, 0, 0)) +>X : Symbol(E.X, Decl(isolatedModulesNonAmbientConstEnum.ts, 1, 14)) + +export var x; +>x : Symbol(x, Decl(isolatedModulesNonAmbientConstEnum.ts, 3, 10)) + diff --git a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.types b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types similarity index 60% rename from tests/baselines/reference/separateCompilationNonAmbientConstEnum.types rename to tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types index ce55b80f41d..d7e83b81070 100644 --- a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.types +++ b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts === +=== tests/cases/compiler/isolatedModulesNonAmbientConstEnum.ts === const enum E { X = 100 }; >E : E diff --git a/tests/baselines/reference/separateCompilationOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt similarity index 100% rename from tests/baselines/reference/separateCompilationOut.errors.txt rename to tests/baselines/reference/isolatedModulesOut.errors.txt diff --git a/tests/baselines/reference/separateCompilationOut.js b/tests/baselines/reference/isolatedModulesOut.js similarity index 60% rename from tests/baselines/reference/separateCompilationOut.js rename to tests/baselines/reference/isolatedModulesOut.js index 67dd2dcfbfa..ca5eb2b7579 100644 --- a/tests/baselines/reference/separateCompilationOut.js +++ b/tests/baselines/reference/isolatedModulesOut.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/separateCompilationOut.ts] //// +//// [tests/cases/compiler/isolatedModulesOut.ts] //// //// [file1.ts] diff --git a/tests/baselines/reference/isolatedModulesPlainFile-AMD.errors.txt b/tests/baselines/reference/isolatedModulesPlainFile-AMD.errors.txt new file mode 100644 index 00000000000..680070a73c8 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-AMD.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesPlainFile-AMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesPlainFile-AMD.ts (1 errors) ==== + + declare function run(a: number): void; + ~~~~~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + run(1); + \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-AMD.js b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js similarity index 57% rename from tests/baselines/reference/separateCompilationPlainFile-AMD.js rename to tests/baselines/reference/isolatedModulesPlainFile-AMD.js index e3e9fc1eaeb..7f4f4219123 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-AMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js @@ -1,10 +1,10 @@ -//// [separateCompilationPlainFile-AMD.ts] +//// [isolatedModulesPlainFile-AMD.ts] declare function run(a: number): void; run(1); -//// [separateCompilationPlainFile-AMD.js] +//// [isolatedModulesPlainFile-AMD.js] define(["require", "exports"], function (require, exports) { run(1); }); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.errors.txt b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.errors.txt new file mode 100644 index 00000000000..d1f0ca3caad --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts (1 errors) ==== + + declare function run(a: number): void; + ~~~~~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + run(1); + \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js new file mode 100644 index 00000000000..7026a7d9bed --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -0,0 +1,8 @@ +//// [isolatedModulesPlainFile-CommonJS.ts] + +declare function run(a: number): void; +run(1); + + +//// [isolatedModulesPlainFile-CommonJS.js] +run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-ES6.errors.txt b/tests/baselines/reference/isolatedModulesPlainFile-ES6.errors.txt new file mode 100644 index 00000000000..d46fce22fd7 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-ES6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesPlainFile-ES6.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesPlainFile-ES6.ts (1 errors) ==== + + declare function run(a: number): void; + ~~~~~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + run(1); + \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesPlainFile-ES6.js b/tests/baselines/reference/isolatedModulesPlainFile-ES6.js new file mode 100644 index 00000000000..245d3fe668f --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-ES6.js @@ -0,0 +1,8 @@ +//// [isolatedModulesPlainFile-ES6.ts] + +declare function run(a: number): void; +run(1); + + +//// [isolatedModulesPlainFile-ES6.js] +run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-System.errors.txt b/tests/baselines/reference/isolatedModulesPlainFile-System.errors.txt new file mode 100644 index 00000000000..fe1a2f80018 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-System.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesPlainFile-System.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesPlainFile-System.ts (1 errors) ==== + + declare function run(a: number): void; + ~~~~~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + run(1); + \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-System.js b/tests/baselines/reference/isolatedModulesPlainFile-System.js similarity index 65% rename from tests/baselines/reference/separateCompilationPlainFile-System.js rename to tests/baselines/reference/isolatedModulesPlainFile-System.js index c256ed7862a..b924a3b21f9 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-System.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-System.js @@ -1,10 +1,10 @@ -//// [separateCompilationPlainFile-System.ts] +//// [isolatedModulesPlainFile-System.ts] declare function run(a: number): void; run(1); -//// [separateCompilationPlainFile-System.js] +//// [isolatedModulesPlainFile-System.js] System.register([], function(exports_1) { return { setters:[], diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.errors.txt b/tests/baselines/reference/isolatedModulesPlainFile-UMD.errors.txt new file mode 100644 index 00000000000..24c5c86f8f8 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/isolatedModulesPlainFile-UMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + + +==== tests/cases/compiler/isolatedModulesPlainFile-UMD.ts (1 errors) ==== + + declare function run(a: number): void; + ~~~~~~~ +!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. + run(1); + \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js similarity index 80% rename from tests/baselines/reference/separateCompilationPlainFile-UMD.js rename to tests/baselines/reference/isolatedModulesPlainFile-UMD.js index 6a145e7d239..0ed6e83a37f 100644 --- a/tests/baselines/reference/separateCompilationPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -1,10 +1,10 @@ -//// [separateCompilationPlainFile-UMD.ts] +//// [isolatedModulesPlainFile-UMD.ts] declare function run(a: number): void; run(1); -//// [separateCompilationPlainFile-UMD.js] +//// [isolatedModulesPlainFile-UMD.js] (function (deps, factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; diff --git a/tests/baselines/reference/separateCompilationSourceMap.errors.txt b/tests/baselines/reference/isolatedModulesSourceMap.errors.txt similarity index 64% rename from tests/baselines/reference/separateCompilationSourceMap.errors.txt rename to tests/baselines/reference/isolatedModulesSourceMap.errors.txt index 56fc5b5cb85..6383e85ecd5 100644 --- a/tests/baselines/reference/separateCompilationSourceMap.errors.txt +++ b/tests/baselines/reference/isolatedModulesSourceMap.errors.txt @@ -2,6 +2,6 @@ error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModule !!! error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'. -==== tests/cases/compiler/separateCompilationSourceMap.ts (0 errors) ==== +==== tests/cases/compiler/isolatedModulesSourceMap.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.js b/tests/baselines/reference/isolatedModulesSourceMap.js new file mode 100644 index 00000000000..ca6f4b4190e --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSourceMap.js @@ -0,0 +1,7 @@ +//// [isolatedModulesSourceMap.ts] + +export var x; + +//// [isolatedModulesSourceMap.js] +export var x; +//# sourceMappingURL=isolatedModulesSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.js.map b/tests/baselines/reference/isolatedModulesSourceMap.js.map new file mode 100644 index 00000000000..8e505dcda7a --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSourceMap.js.map @@ -0,0 +1,2 @@ +//// [isolatedModulesSourceMap.js.map] +{"version":3,"file":"isolatedModulesSourceMap.js","sourceRoot":"","sources":["isolatedModulesSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSourceMap.sourcemap.txt b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt similarity index 61% rename from tests/baselines/reference/separateCompilationSourceMap.sourcemap.txt rename to tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt index 74e0d73d7e0..5c6b7659bc6 100644 --- a/tests/baselines/reference/separateCompilationSourceMap.sourcemap.txt +++ b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt @@ -1,19 +1,19 @@ =================================================================== -JsFile: separateCompilationSourceMap.js -mapUrl: separateCompilationSourceMap.js.map +JsFile: isolatedModulesSourceMap.js +mapUrl: isolatedModulesSourceMap.js.map sourceRoot: -sources: separateCompilationSourceMap.ts +sources: isolatedModulesSourceMap.ts =================================================================== ------------------------------------------------------------------- -emittedFile:tests/cases/compiler/separateCompilationSourceMap.js -sourceFile:separateCompilationSourceMap.ts +emittedFile:tests/cases/compiler/isolatedModulesSourceMap.js +sourceFile:isolatedModulesSourceMap.ts ------------------------------------------------------------------- >>>export var x; 1 > 2 >^^^^^^^^^^^ 3 > ^ 4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >export var @@ -24,4 +24,4 @@ sourceFile:separateCompilationSourceMap.ts 3 >Emitted(1, 13) Source(2, 13) + SourceIndex(0) 4 >Emitted(1, 14) Source(2, 14) + SourceIndex(0) --- ->>>//# sourceMappingURL=separateCompilationSourceMap.js.map \ No newline at end of file +>>>//# sourceMappingURL=isolatedModulesSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSpecifiedModule.js b/tests/baselines/reference/isolatedModulesSpecifiedModule.js new file mode 100644 index 00000000000..6e868360e71 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSpecifiedModule.js @@ -0,0 +1,5 @@ +//// [isolatedModulesSpecifiedModule.ts] +export var x; + +//// [isolatedModulesSpecifiedModule.js] +exports.x; diff --git a/tests/baselines/reference/isolatedModulesSpecifiedModule.symbols b/tests/baselines/reference/isolatedModulesSpecifiedModule.symbols new file mode 100644 index 00000000000..91ede682d7c --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSpecifiedModule.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/isolatedModulesSpecifiedModule.ts === +export var x; +>x : Symbol(x, Decl(isolatedModulesSpecifiedModule.ts, 0, 10)) + diff --git a/tests/baselines/reference/isolatedModulesSpecifiedModule.types b/tests/baselines/reference/isolatedModulesSpecifiedModule.types new file mode 100644 index 00000000000..8dee90a199f --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSpecifiedModule.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/isolatedModulesSpecifiedModule.ts === +export var x; +>x : any + diff --git a/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt b/tests/baselines/reference/isolatedModulesUnspecifiedModule.errors.txt similarity index 72% rename from tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt rename to tests/baselines/reference/isolatedModulesUnspecifiedModule.errors.txt index 0691be32c7c..7d290bcae44 100644 --- a/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt +++ b/tests/baselines/reference/isolatedModulesUnspecifiedModule.errors.txt @@ -2,5 +2,5 @@ error TS5047: Option 'isolatedModules' can only be used when either option'--mod !!! error TS5047: Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher. -==== tests/cases/compiler/separateCompilationUnspecifiedModule.ts (0 errors) ==== +==== tests/cases/compiler/isolatedModulesUnspecifiedModule.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesUnspecifiedModule.js b/tests/baselines/reference/isolatedModulesUnspecifiedModule.js new file mode 100644 index 00000000000..104eda6c052 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesUnspecifiedModule.js @@ -0,0 +1,5 @@ +//// [isolatedModulesUnspecifiedModule.ts] +export var x; + +//// [isolatedModulesUnspecifiedModule.js] +exports.x; diff --git a/tests/baselines/reference/separateCompilationWithDeclarationFile.js b/tests/baselines/reference/isolatedModulesWithDeclarationFile.js similarity index 57% rename from tests/baselines/reference/separateCompilationWithDeclarationFile.js rename to tests/baselines/reference/isolatedModulesWithDeclarationFile.js index 71d7ef41929..42d091b6108 100644 --- a/tests/baselines/reference/separateCompilationWithDeclarationFile.js +++ b/tests/baselines/reference/isolatedModulesWithDeclarationFile.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/separateCompilationWithDeclarationFile.ts] //// +//// [tests/cases/compiler/isolatedModulesWithDeclarationFile.ts] //// //// [file1.d.ts] diff --git a/tests/baselines/reference/separateCompilationWithDeclarationFile.symbols b/tests/baselines/reference/isolatedModulesWithDeclarationFile.symbols similarity index 100% rename from tests/baselines/reference/separateCompilationWithDeclarationFile.symbols rename to tests/baselines/reference/isolatedModulesWithDeclarationFile.symbols diff --git a/tests/baselines/reference/separateCompilationWithDeclarationFile.types b/tests/baselines/reference/isolatedModulesWithDeclarationFile.types similarity index 100% rename from tests/baselines/reference/separateCompilationWithDeclarationFile.types rename to tests/baselines/reference/isolatedModulesWithDeclarationFile.types diff --git a/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt b/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt deleted file mode 100644 index ea55115e957..00000000000 --- a/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationAmbientConstEnum.ts (1 errors) ==== - - - declare const enum E { X = 1} - ~ -!!! error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided. - export var y; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationAmbientConstEnum.js b/tests/baselines/reference/separateCompilationAmbientConstEnum.js deleted file mode 100644 index 5b3af0957e7..00000000000 --- a/tests/baselines/reference/separateCompilationAmbientConstEnum.js +++ /dev/null @@ -1,8 +0,0 @@ -//// [separateCompilationAmbientConstEnum.ts] - - -declare const enum E { X = 1} -export var y; - -//// [separateCompilationAmbientConstEnum.js] -export var y; diff --git a/tests/baselines/reference/separateCompilationDeclaration.js b/tests/baselines/reference/separateCompilationDeclaration.js deleted file mode 100644 index 33d64b088de..00000000000 --- a/tests/baselines/reference/separateCompilationDeclaration.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [separateCompilationDeclaration.ts] - -export var x; - -//// [separateCompilationDeclaration.js] -export var x; - - -//// [separateCompilationDeclaration.d.ts] -export declare var x: any; diff --git a/tests/baselines/reference/separateCompilationES6.js b/tests/baselines/reference/separateCompilationES6.js deleted file mode 100644 index cf05e5590a8..00000000000 --- a/tests/baselines/reference/separateCompilationES6.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [separateCompilationES6.ts] -export var x; - -//// [separateCompilationES6.js] -export var x; diff --git a/tests/baselines/reference/separateCompilationES6.symbols b/tests/baselines/reference/separateCompilationES6.symbols deleted file mode 100644 index 737d5e41365..00000000000 --- a/tests/baselines/reference/separateCompilationES6.symbols +++ /dev/null @@ -1,4 +0,0 @@ -=== tests/cases/compiler/separateCompilationES6.ts === -export var x; ->x : Symbol(x, Decl(separateCompilationES6.ts, 0, 10)) - diff --git a/tests/baselines/reference/separateCompilationES6.types b/tests/baselines/reference/separateCompilationES6.types deleted file mode 100644 index 70381906800..00000000000 --- a/tests/baselines/reference/separateCompilationES6.types +++ /dev/null @@ -1,4 +0,0 @@ -=== tests/cases/compiler/separateCompilationES6.ts === -export var x; ->x : any - diff --git a/tests/baselines/reference/separateCompilationImportExportElision.errors.txt b/tests/baselines/reference/separateCompilationImportExportElision.errors.txt deleted file mode 100644 index 0bac01d8134..00000000000 --- a/tests/baselines/reference/separateCompilationImportExportElision.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -tests/cases/compiler/separateCompilationImportExportElision.ts(2,17): error TS2307: Cannot find module 'module'. -tests/cases/compiler/separateCompilationImportExportElision.ts(3,18): error TS2307: Cannot find module 'module'. -tests/cases/compiler/separateCompilationImportExportElision.ts(4,21): error TS2307: Cannot find module 'module'. -tests/cases/compiler/separateCompilationImportExportElision.ts(12,18): error TS2307: Cannot find module 'module'. - - -==== tests/cases/compiler/separateCompilationImportExportElision.ts (4 errors) ==== - - import {c} from "module" - ~~~~~~~~ -!!! error TS2307: Cannot find module 'module'. - import {c2} from "module" - ~~~~~~~~ -!!! error TS2307: Cannot find module 'module'. - import * as ns from "module" - ~~~~~~~~ -!!! error TS2307: Cannot find module 'module'. - - class C extends c2.C { - } - - let x = new c(); - let y = ns.value; - - export {c1} from "module"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'module'. - export var z = x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt b/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt deleted file mode 100644 index 7c242e90f12..00000000000 --- a/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/separateCompilationNoExternalModule.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationNoExternalModule.ts (1 errors) ==== - - var x; - ~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationNoExternalModule.js b/tests/baselines/reference/separateCompilationNoExternalModule.js deleted file mode 100644 index 9ddc8bdef2c..00000000000 --- a/tests/baselines/reference/separateCompilationNoExternalModule.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [separateCompilationNoExternalModule.ts] - -var x; - -//// [separateCompilationNoExternalModule.js] -var x; diff --git a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.symbols b/tests/baselines/reference/separateCompilationNonAmbientConstEnum.symbols deleted file mode 100644 index da3f7ce6452..00000000000 --- a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.symbols +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts === - -const enum E { X = 100 }; ->E : Symbol(E, Decl(separateCompilationNonAmbientConstEnum.ts, 0, 0)) ->X : Symbol(E.X, Decl(separateCompilationNonAmbientConstEnum.ts, 1, 14)) - -var e = E.X; ->e : Symbol(e, Decl(separateCompilationNonAmbientConstEnum.ts, 2, 3)) ->E.X : Symbol(E.X, Decl(separateCompilationNonAmbientConstEnum.ts, 1, 14)) ->E : Symbol(E, Decl(separateCompilationNonAmbientConstEnum.ts, 0, 0)) ->X : Symbol(E.X, Decl(separateCompilationNonAmbientConstEnum.ts, 1, 14)) - -export var x; ->x : Symbol(x, Decl(separateCompilationNonAmbientConstEnum.ts, 3, 10)) - diff --git a/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt deleted file mode 100644 index 329299f5130..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-AMD.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationPlainFile-AMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationPlainFile-AMD.ts (1 errors) ==== - - declare function run(a: number): void; - ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - run(1); - \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt deleted file mode 100644 index e72a4a76b71..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts (1 errors) ==== - - declare function run(a: number): void; - ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - run(1); - \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.js b/tests/baselines/reference/separateCompilationPlainFile-CommonJS.js deleted file mode 100644 index cd82cdf20a6..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-CommonJS.js +++ /dev/null @@ -1,8 +0,0 @@ -//// [separateCompilationPlainFile-CommonJS.ts] - -declare function run(a: number): void; -run(1); - - -//// [separateCompilationPlainFile-CommonJS.js] -run(1); diff --git a/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt deleted file mode 100644 index 602d41ce948..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-ES6.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationPlainFile-ES6.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationPlainFile-ES6.ts (1 errors) ==== - - declare function run(a: number): void; - ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - run(1); - \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-ES6.js b/tests/baselines/reference/separateCompilationPlainFile-ES6.js deleted file mode 100644 index 1cb6082f134..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-ES6.js +++ /dev/null @@ -1,8 +0,0 @@ -//// [separateCompilationPlainFile-ES6.ts] - -declare function run(a: number): void; -run(1); - - -//// [separateCompilationPlainFile-ES6.js] -run(1); diff --git a/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt deleted file mode 100644 index a6d14edd61a..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-System.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationPlainFile-System.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationPlainFile-System.ts (1 errors) ==== - - declare function run(a: number): void; - ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - run(1); - \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt b/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt deleted file mode 100644 index d15098a96c1..00000000000 --- a/tests/baselines/reference/separateCompilationPlainFile-UMD.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/separateCompilationPlainFile-UMD.ts(2,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - - -==== tests/cases/compiler/separateCompilationPlainFile-UMD.ts (1 errors) ==== - - declare function run(a: number): void; - ~~~~~~~ -!!! error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. - run(1); - \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSourceMap.js b/tests/baselines/reference/separateCompilationSourceMap.js deleted file mode 100644 index 1e8f141eb47..00000000000 --- a/tests/baselines/reference/separateCompilationSourceMap.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [separateCompilationSourceMap.ts] - -export var x; - -//// [separateCompilationSourceMap.js] -export var x; -//# sourceMappingURL=separateCompilationSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSourceMap.js.map b/tests/baselines/reference/separateCompilationSourceMap.js.map deleted file mode 100644 index 68c4e2c78db..00000000000 --- a/tests/baselines/reference/separateCompilationSourceMap.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [separateCompilationSourceMap.js.map] -{"version":3,"file":"separateCompilationSourceMap.js","sourceRoot":"","sources":["separateCompilationSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSpecifiedModule.js b/tests/baselines/reference/separateCompilationSpecifiedModule.js deleted file mode 100644 index 5f3c7ceb39c..00000000000 --- a/tests/baselines/reference/separateCompilationSpecifiedModule.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [separateCompilationSpecifiedModule.ts] -export var x; - -//// [separateCompilationSpecifiedModule.js] -exports.x; diff --git a/tests/baselines/reference/separateCompilationSpecifiedModule.symbols b/tests/baselines/reference/separateCompilationSpecifiedModule.symbols deleted file mode 100644 index a69b579b34d..00000000000 --- a/tests/baselines/reference/separateCompilationSpecifiedModule.symbols +++ /dev/null @@ -1,4 +0,0 @@ -=== tests/cases/compiler/separateCompilationSpecifiedModule.ts === -export var x; ->x : Symbol(x, Decl(separateCompilationSpecifiedModule.ts, 0, 10)) - diff --git a/tests/baselines/reference/separateCompilationSpecifiedModule.types b/tests/baselines/reference/separateCompilationSpecifiedModule.types deleted file mode 100644 index 497f63faf62..00000000000 --- a/tests/baselines/reference/separateCompilationSpecifiedModule.types +++ /dev/null @@ -1,4 +0,0 @@ -=== tests/cases/compiler/separateCompilationSpecifiedModule.ts === -export var x; ->x : any - diff --git a/tests/baselines/reference/separateCompilationUnspecifiedModule.js b/tests/baselines/reference/separateCompilationUnspecifiedModule.js deleted file mode 100644 index 0f2e5c71a87..00000000000 --- a/tests/baselines/reference/separateCompilationUnspecifiedModule.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [separateCompilationUnspecifiedModule.ts] -export var x; - -//// [separateCompilationUnspecifiedModule.js] -exports.x; diff --git a/tests/cases/compiler/separateCompilationAmbientConstEnum.ts b/tests/cases/compiler/isolatedModulesAmbientConstEnum.ts similarity index 100% rename from tests/cases/compiler/separateCompilationAmbientConstEnum.ts rename to tests/cases/compiler/isolatedModulesAmbientConstEnum.ts diff --git a/tests/cases/compiler/separateCompilationDeclaration.ts b/tests/cases/compiler/isolatedModulesDeclaration.ts similarity index 100% rename from tests/cases/compiler/separateCompilationDeclaration.ts rename to tests/cases/compiler/isolatedModulesDeclaration.ts diff --git a/tests/cases/compiler/separateCompilationES6.ts b/tests/cases/compiler/isolatedModulesES6.ts similarity index 100% rename from tests/cases/compiler/separateCompilationES6.ts rename to tests/cases/compiler/isolatedModulesES6.ts diff --git a/tests/cases/compiler/separateCompilationImportExportElision.ts b/tests/cases/compiler/isolatedModulesImportExportElision.ts similarity index 100% rename from tests/cases/compiler/separateCompilationImportExportElision.ts rename to tests/cases/compiler/isolatedModulesImportExportElision.ts diff --git a/tests/cases/compiler/separateCompilationNoEmitOnError.ts b/tests/cases/compiler/isolatedModulesNoEmitOnError.ts similarity index 100% rename from tests/cases/compiler/separateCompilationNoEmitOnError.ts rename to tests/cases/compiler/isolatedModulesNoEmitOnError.ts diff --git a/tests/cases/compiler/separateCompilationNoExternalModule.ts b/tests/cases/compiler/isolatedModulesNoExternalModule.ts similarity index 100% rename from tests/cases/compiler/separateCompilationNoExternalModule.ts rename to tests/cases/compiler/isolatedModulesNoExternalModule.ts diff --git a/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts b/tests/cases/compiler/isolatedModulesNonAmbientConstEnum.ts similarity index 100% rename from tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts rename to tests/cases/compiler/isolatedModulesNonAmbientConstEnum.ts diff --git a/tests/cases/compiler/separateCompilationOut.ts b/tests/cases/compiler/isolatedModulesOut.ts similarity index 100% rename from tests/cases/compiler/separateCompilationOut.ts rename to tests/cases/compiler/isolatedModulesOut.ts diff --git a/tests/cases/compiler/separateCompilationPlainFile-AMD.ts b/tests/cases/compiler/isolatedModulesPlainFile-AMD.ts similarity index 100% rename from tests/cases/compiler/separateCompilationPlainFile-AMD.ts rename to tests/cases/compiler/isolatedModulesPlainFile-AMD.ts diff --git a/tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts b/tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts similarity index 100% rename from tests/cases/compiler/separateCompilationPlainFile-CommonJS.ts rename to tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts diff --git a/tests/cases/compiler/separateCompilationPlainFile-ES6.ts b/tests/cases/compiler/isolatedModulesPlainFile-ES6.ts similarity index 100% rename from tests/cases/compiler/separateCompilationPlainFile-ES6.ts rename to tests/cases/compiler/isolatedModulesPlainFile-ES6.ts diff --git a/tests/cases/compiler/separateCompilationPlainFile-System.ts b/tests/cases/compiler/isolatedModulesPlainFile-System.ts similarity index 100% rename from tests/cases/compiler/separateCompilationPlainFile-System.ts rename to tests/cases/compiler/isolatedModulesPlainFile-System.ts diff --git a/tests/cases/compiler/separateCompilationPlainFile-UMD.ts b/tests/cases/compiler/isolatedModulesPlainFile-UMD.ts similarity index 100% rename from tests/cases/compiler/separateCompilationPlainFile-UMD.ts rename to tests/cases/compiler/isolatedModulesPlainFile-UMD.ts diff --git a/tests/cases/compiler/separateCompilationSourceMap.ts b/tests/cases/compiler/isolatedModulesSourceMap.ts similarity index 100% rename from tests/cases/compiler/separateCompilationSourceMap.ts rename to tests/cases/compiler/isolatedModulesSourceMap.ts diff --git a/tests/cases/compiler/separateCompilationSpecifiedModule.ts b/tests/cases/compiler/isolatedModulesSpecifiedModule.ts similarity index 100% rename from tests/cases/compiler/separateCompilationSpecifiedModule.ts rename to tests/cases/compiler/isolatedModulesSpecifiedModule.ts diff --git a/tests/cases/compiler/separateCompilationUnspecifiedModule.ts b/tests/cases/compiler/isolatedModulesUnspecifiedModule.ts similarity index 100% rename from tests/cases/compiler/separateCompilationUnspecifiedModule.ts rename to tests/cases/compiler/isolatedModulesUnspecifiedModule.ts diff --git a/tests/cases/compiler/separateCompilationWithDeclarationFile.ts b/tests/cases/compiler/isolatedModulesWithDeclarationFile.ts similarity index 100% rename from tests/cases/compiler/separateCompilationWithDeclarationFile.ts rename to tests/cases/compiler/isolatedModulesWithDeclarationFile.ts From f5bcaa3bf88cf95c9b68f3dc2db476e766f99c89 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 12 May 2015 15:49:41 -0700 Subject: [PATCH 03/26] Emit [...a] as a.slice() to ensure a is copied --- src/compiler/emitter.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6d5146a6801..37e1f231bcf 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1366,7 +1366,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return true; } - function emitListWithSpread(elements: Expression[], multiLine: boolean, trailingComma: boolean) { + function emitListWithSpread(elements: Expression[], alwaysCopy: boolean, multiLine: boolean, trailingComma: boolean) { let pos = 0; let group = 0; let length = elements.length; @@ -1383,6 +1383,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { e = (e).expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy) { + write(".slice()"); + } } else { let i = pos; @@ -1422,7 +1425,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("]"); } else { - emitListWithSpread(elements, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, + emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -1847,7 +1850,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("void 0"); } write(", "); - emitListWithSpread(node.arguments, /*multiLine*/ false, /*trailingComma*/ false); + emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); write(")"); } From a4294a686458039dd3fef5e5a3ebd2e01b4364bf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 12 May 2015 15:51:20 -0700 Subject: [PATCH 04/26] Accepting new baselines --- tests/baselines/reference/arrayLiteralSpread.js | 6 +++--- tests/baselines/reference/arrayLiterals2ES5.js | 16 ++++++++-------- tests/baselines/reference/arrayLiterals3.js | 4 ++-- ...turingArrayBindingPatternAndAssignment1ES5.js | 2 +- ...ructuringArrayBindingPatternAndAssignment2.js | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/arrayLiteralSpread.js b/tests/baselines/reference/arrayLiteralSpread.js index 73a60714526..5e4fcedf9d6 100644 --- a/tests/baselines/reference/arrayLiteralSpread.js +++ b/tests/baselines/reference/arrayLiteralSpread.js @@ -26,7 +26,7 @@ function f2() { //// [arrayLiteralSpread.js] function f0() { var a = [1, 2, 3]; - var a1 = a; + var a1 = a.slice(); var a2 = [1].concat(a); var a3 = [1, 2].concat(a); var a4 = a.concat([1]); @@ -41,6 +41,6 @@ function f1() { var b; } function f2() { - var a = []; - var b = [5]; + var a = [].slice().slice().slice().slice().slice(); + var b = [5].slice().slice().slice().slice().slice(); } diff --git a/tests/baselines/reference/arrayLiterals2ES5.js b/tests/baselines/reference/arrayLiterals2ES5.js index 0ff82e90970..689655fb302 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.js +++ b/tests/baselines/reference/arrayLiterals2ES5.js @@ -93,12 +93,12 @@ var temp2 = [[1, 2, 3], ["hello", "string"]]; var temp3 = [undefined, null, undefined]; var temp4 = []; var d0 = [1, true].concat(temp); // has type (string|number|boolean)[] -var d1 = temp; // has type string[] -var d2 = temp1; -var d3 = temp1; +var d1 = temp.slice(); // has type string[] +var d2 = temp1.slice(); +var d3 = temp1.slice(); var d4 = temp.concat(temp1); -var d5 = temp3; -var d6 = temp4; -var d7 = temp1; -var d8 = [temp1]; -var d9 = [temp1].concat(["hello"]); +var d5 = temp3.slice(); +var d6 = temp4.slice(); +var d7 = temp1.slice().slice(); +var d8 = [temp1.slice()]; +var d9 = [temp1.slice()].concat(["hello"]); diff --git a/tests/baselines/reference/arrayLiterals3.js b/tests/baselines/reference/arrayLiterals3.js index 091c6148068..4769c069988 100644 --- a/tests/baselines/reference/arrayLiterals3.js +++ b/tests/baselines/reference/arrayLiterals3.js @@ -55,6 +55,6 @@ var _a = [1, 2, "string", true], b1 = _a[0], b2 = _a[1]; var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2 = [[1, 2, 3], ["hello", "string"]]; -var c0 = temp2; // Error -var c1 = temp1; // Error cannot assign number[] to [number, number, number] +var c0 = temp2.slice(); // Error +var c1 = temp1.slice(); // Error cannot assign number[] to [number, number, number] var c2 = temp1.concat(temp); // Error cannot assign (number|string)[] to number[] diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js index bf71064264a..4f071b5e5ec 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js @@ -88,7 +88,7 @@ var _e = foo(), b6 = _e[0], b7 = _e[1]; var b8 = foo().slice(0); // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1, 2, 3]; -var _f = temp, c0 = _f[0], c1 = _f[1]; +var _f = temp.slice(), c0 = _f[0], c1 = _f[1]; var c2 = [][0]; var _g = [[[]], [[[[]]]]], c3 = _g[0][0][0], c4 = _g[1][0][0][0][0]; var _h = [[1], true], c5 = _h[0][0], c6 = _h[1]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js index fdbf47fd970..223090ea8ca 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js @@ -50,8 +50,8 @@ var _c = bar(), _d = _c[0], b3 = _d === void 0 ? "string" : _d, b4 = _c[1], b5 = // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1, 2, 3]; -var _e = temp, c0 = _e[0], c1 = _e[1]; // Error -var _f = temp, c2 = _f[0], c3 = _f[1]; // Error +var _e = temp.slice(), c0 = _e[0], c1 = _e[1]; // Error +var _f = temp.slice(), c2 = _f[0], c3 = _f[1]; // Error function foo(idx) { return { 2: true From de8b2fabb9f6b381ff271bb2a91f40f1c02a8561 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 12 May 2015 16:53:53 -0700 Subject: [PATCH 05/26] Optimize spread to not generate x.slice() when x is an array literal --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 37e1f231bcf..4c979486ff3 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1383,7 +1383,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { e = (e).expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && alwaysCopy) { + if (pos === length && group === 0 && alwaysCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) { write(".slice()"); } } From b355412ef6311c0ca30c28842e31e1e2bea84080 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 12 May 2015 16:54:34 -0700 Subject: [PATCH 06/26] Accepting new baselines --- tests/baselines/reference/arrayLiteralSpread.js | 4 ++-- tests/baselines/reference/arrayLiterals2ES5.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/arrayLiteralSpread.js b/tests/baselines/reference/arrayLiteralSpread.js index 5e4fcedf9d6..3561189671e 100644 --- a/tests/baselines/reference/arrayLiteralSpread.js +++ b/tests/baselines/reference/arrayLiteralSpread.js @@ -41,6 +41,6 @@ function f1() { var b; } function f2() { - var a = [].slice().slice().slice().slice().slice(); - var b = [5].slice().slice().slice().slice().slice(); + var a = []; + var b = [5]; } diff --git a/tests/baselines/reference/arrayLiterals2ES5.js b/tests/baselines/reference/arrayLiterals2ES5.js index 689655fb302..6a81ab465a2 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.js +++ b/tests/baselines/reference/arrayLiterals2ES5.js @@ -99,6 +99,6 @@ var d3 = temp1.slice(); var d4 = temp.concat(temp1); var d5 = temp3.slice(); var d6 = temp4.slice(); -var d7 = temp1.slice().slice(); +var d7 = temp1.slice(); var d8 = [temp1.slice()]; var d9 = [temp1.slice()].concat(["hello"]); From 65735782990c1a18b86b8189f20576f1c682eacc Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 12 May 2015 22:59:29 -0700 Subject: [PATCH 07/26] handle triple slashes in url schema 'file' correctly --- src/compiler/core.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9b987ba77c6..db47efa9670 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -459,6 +459,14 @@ module ts { if (path.charCodeAt(2) === CharacterCodes.slash) return 3; return 2; } + // Per RFC 1738'file' URI schema has a shape file:/// + // if is omitted then it is assumed that host value is'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is correct URI + // file://folder2/file2 - this is incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } let idx = path.indexOf('://'); if (idx !== -1) return idx + 3 return 0; From 2a1df727debe18c98b6b2bc301f8d81690515521 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 15 May 2015 00:42:04 -0700 Subject: [PATCH 08/26] addressed PR feedback --- src/compiler/core.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index db47efa9670..c753f7ff42d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -459,16 +459,18 @@ module ts { if (path.charCodeAt(2) === CharacterCodes.slash) return 3; return 2; } - // Per RFC 1738'file' URI schema has a shape file:/// - // if is omitted then it is assumed that host value is'localhost', + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', // however slash after the omitted is not removed. - // file:///folder1/file1 - this is correct URI - // file://folder2/file2 - this is incorrect URI + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } let idx = path.indexOf('://'); - if (idx !== -1) return idx + 3 + if (idx !== -1) { + return idx + "://".length; + } return 0; } From 87ed20bd57c1fd0acc561869b0b5ad604b2a96ee Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 11 May 2015 00:07:49 -0700 Subject: [PATCH 09/26] system: fix emit for exports of non-top level entities, fix emit for enums --- src/compiler/emitter.ts | 61 ++++++++++++++++--- .../systemModuleDeclarationMerging.js | 43 +++++++++++++ .../systemModuleDeclarationMerging.symbols | 23 +++++++ .../systemModuleDeclarationMerging.types | 23 +++++++ .../systemModuleNonTopLevelModuleMembers.js | 58 ++++++++++++++++++ ...stemModuleNonTopLevelModuleMembers.symbols | 33 ++++++++++ ...systemModuleNonTopLevelModuleMembers.types | 33 ++++++++++ .../systemModuleDeclarationMerging.ts | 11 ++++ .../systemModuleNonTopLevelModuleMembers.ts | 14 +++++ 9 files changed, 289 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/systemModuleDeclarationMerging.js create mode 100644 tests/baselines/reference/systemModuleDeclarationMerging.symbols create mode 100644 tests/baselines/reference/systemModuleDeclarationMerging.types create mode 100644 tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js create mode 100644 tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols create mode 100644 tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types create mode 100644 tests/cases/compiler/systemModuleDeclarationMerging.ts create mode 100644 tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4c979486ff3..9c6b4171890 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2642,7 +2642,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLine(); emitStart(node); - if (compilerOptions.module === ModuleKind.System) { + // emit call to exported only for top level nodes + if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(`${exportFunctionForFile}("`); @@ -4406,7 +4407,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export) { + if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted writeLine(); emitStart(node); write("var "); @@ -4417,6 +4419,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(";"); } if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { + if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + // write the call to exported for enum + writeLine(); + write(`${exportFunctionForFile}("`); + emitDeclarationName(node); + write(`", `); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -5097,7 +5108,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // in theory we should hoist only exported functions and its dependencies // in practice to simplify things we'll hoist all source level functions and variable declaration // including variables declarations for module and class declarations - let hoistedVars: (Identifier | ClassDeclaration | ModuleDeclaration)[]; + let hoistedVars: (Identifier | ClassDeclaration | ModuleDeclaration | EnumDeclaration)[]; let hoistedFunctionDeclarations: FunctionDeclaration[]; let exportedDeclarations: (Identifier | Declaration)[]; @@ -5106,13 +5117,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (hoistedVars) { writeLine(); write("var "); + let seen: Map = {}; for (let i = 0; i < hoistedVars.length; ++i) { let local = hoistedVars[i]; + let name = local.kind === SyntaxKind.Identifier + ? local + : (local).name; + + if (name) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + let text = unescapeIdentifier(name.text); + if (hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { write(", "); } - if (local.kind === SyntaxKind.ClassDeclaration || local.kind === SyntaxKind.ModuleDeclaration) { - emitDeclarationName(local); + + if (local.kind === SyntaxKind.ClassDeclaration || local.kind === SyntaxKind.ModuleDeclaration || local.kind === SyntaxKind.EnumDeclaration) { + emitDeclarationName(local); } else { emit(local); @@ -5156,7 +5184,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } if (node.kind === SyntaxKind.ClassDeclaration) { - // TODO: rename block scoped classes if (!hoistedVars) { hoistedVars = []; } @@ -5165,12 +5192,26 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return; } - if (node.kind === SyntaxKind.ModuleDeclaration && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === SyntaxKind.EnumDeclaration) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); } - hoistedVars.push(node); + return; + } + + if (node.kind === SyntaxKind.ModuleDeclaration) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); + } return; } diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.js b/tests/baselines/reference/systemModuleDeclarationMerging.js new file mode 100644 index 00000000000..b745ed04891 --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.js @@ -0,0 +1,43 @@ +//// [systemModuleDeclarationMerging.ts] + +export function F() {} +export module F { var x; } + +export class C {} +export module C { var x; } + +export enum E {} +export module E { var x; } + +//// [systemModuleDeclarationMerging.js] +System.register([], function(exports_1) { + var F, C, E; + function F() { } + exports_1("F", F); + return { + setters:[], + execute: function() { + (function (F) { + var x; + })(F = F || (F = {})); + exports_1("F", F) + C = (function () { + function C() { + } + return C; + })(); + exports_1("C", C); + (function (C) { + var x; + })(C = C || (C = {})); + exports_1("C", C) + (function (E) { + })(E || (E = {})); + exports_1("E", E) + (function (E) { + var x; + })(E = E || (E = {})); + exports_1("E", E) + } + } +}); diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.symbols b/tests/baselines/reference/systemModuleDeclarationMerging.symbols new file mode 100644 index 00000000000..8efce4022ba --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/systemModuleDeclarationMerging.ts === + +export function F() {} +>F : Symbol(F, Decl(systemModuleDeclarationMerging.ts, 0, 0), Decl(systemModuleDeclarationMerging.ts, 1, 22)) + +export module F { var x; } +>F : Symbol(F, Decl(systemModuleDeclarationMerging.ts, 0, 0), Decl(systemModuleDeclarationMerging.ts, 1, 22)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 2, 21)) + +export class C {} +>C : Symbol(C, Decl(systemModuleDeclarationMerging.ts, 2, 26), Decl(systemModuleDeclarationMerging.ts, 4, 17)) + +export module C { var x; } +>C : Symbol(C, Decl(systemModuleDeclarationMerging.ts, 2, 26), Decl(systemModuleDeclarationMerging.ts, 4, 17)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 5, 21)) + +export enum E {} +>E : Symbol(E, Decl(systemModuleDeclarationMerging.ts, 5, 26), Decl(systemModuleDeclarationMerging.ts, 7, 16)) + +export module E { var x; } +>E : Symbol(E, Decl(systemModuleDeclarationMerging.ts, 5, 26), Decl(systemModuleDeclarationMerging.ts, 7, 16)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 8, 21)) + diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.types b/tests/baselines/reference/systemModuleDeclarationMerging.types new file mode 100644 index 00000000000..20bf1e67f51 --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/systemModuleDeclarationMerging.ts === + +export function F() {} +>F : typeof F + +export module F { var x; } +>F : typeof F +>x : any + +export class C {} +>C : C + +export module C { var x; } +>C : typeof C +>x : any + +export enum E {} +>E : E + +export module E { var x; } +>E : typeof E +>x : any + diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js new file mode 100644 index 00000000000..87e96259bf1 --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js @@ -0,0 +1,58 @@ +//// [systemModuleNonTopLevelModuleMembers.ts] + +export class TopLevelClass {} +export module TopLevelModule {var v;} +export function TopLevelFunction(): void {} +export enum TopLevelEnum {E} + +export module TopLevelModule2 { + export class NonTopLevelClass {} + export module NonTopLevelModule {var v;} + export function NonTopLevelFunction(): void {} + export enum NonTopLevelEnum {E} +} + +//// [systemModuleNonTopLevelModuleMembers.js] +System.register([], function(exports_1) { + var TopLevelClass, TopLevelModule, TopLevelEnum, TopLevelModule2; + function TopLevelFunction() { } + exports_1("TopLevelFunction", TopLevelFunction); + return { + setters:[], + execute: function() { + TopLevelClass = (function () { + function TopLevelClass() { + } + return TopLevelClass; + })(); + exports_1("TopLevelClass", TopLevelClass); + (function (TopLevelModule) { + var v; + })(TopLevelModule = TopLevelModule || (TopLevelModule = {})); + exports_1("TopLevelModule", TopLevelModule) + (function (TopLevelEnum) { + TopLevelEnum[TopLevelEnum["E"] = 0] = "E"; + })(TopLevelEnum || (TopLevelEnum = {})); + exports_1("TopLevelEnum", TopLevelEnum) + (function (TopLevelModule2) { + var NonTopLevelClass = (function () { + function NonTopLevelClass() { + } + return NonTopLevelClass; + })(); + TopLevelModule2.NonTopLevelClass = NonTopLevelClass; + var NonTopLevelModule; + (function (NonTopLevelModule) { + var v; + })(NonTopLevelModule = TopLevelModule2.NonTopLevelModule || (TopLevelModule2.NonTopLevelModule = {})); + function NonTopLevelFunction() { } + TopLevelModule2.NonTopLevelFunction = NonTopLevelFunction; + (function (NonTopLevelEnum) { + NonTopLevelEnum[NonTopLevelEnum["E"] = 0] = "E"; + })(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {})); + var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum; + })(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {})); + exports_1("TopLevelModule2", TopLevelModule2) + } + } +}); diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols new file mode 100644 index 00000000000..e0b69c71a2f --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts === + +export class TopLevelClass {} +>TopLevelClass : Symbol(TopLevelClass, Decl(systemModuleNonTopLevelModuleMembers.ts, 0, 0)) + +export module TopLevelModule {var v;} +>TopLevelModule : Symbol(TopLevelModule, Decl(systemModuleNonTopLevelModuleMembers.ts, 1, 29)) +>v : Symbol(v, Decl(systemModuleNonTopLevelModuleMembers.ts, 2, 33)) + +export function TopLevelFunction(): void {} +>TopLevelFunction : Symbol(TopLevelFunction, Decl(systemModuleNonTopLevelModuleMembers.ts, 2, 37)) + +export enum TopLevelEnum {E} +>TopLevelEnum : Symbol(TopLevelEnum, Decl(systemModuleNonTopLevelModuleMembers.ts, 3, 43)) +>E : Symbol(TopLevelEnum.E, Decl(systemModuleNonTopLevelModuleMembers.ts, 4, 26)) + +export module TopLevelModule2 { +>TopLevelModule2 : Symbol(TopLevelModule2, Decl(systemModuleNonTopLevelModuleMembers.ts, 4, 28)) + + export class NonTopLevelClass {} +>NonTopLevelClass : Symbol(NonTopLevelClass, Decl(systemModuleNonTopLevelModuleMembers.ts, 6, 31)) + + export module NonTopLevelModule {var v;} +>NonTopLevelModule : Symbol(NonTopLevelModule, Decl(systemModuleNonTopLevelModuleMembers.ts, 7, 36)) +>v : Symbol(v, Decl(systemModuleNonTopLevelModuleMembers.ts, 8, 40)) + + export function NonTopLevelFunction(): void {} +>NonTopLevelFunction : Symbol(NonTopLevelFunction, Decl(systemModuleNonTopLevelModuleMembers.ts, 8, 44)) + + export enum NonTopLevelEnum {E} +>NonTopLevelEnum : Symbol(NonTopLevelEnum, Decl(systemModuleNonTopLevelModuleMembers.ts, 9, 50)) +>E : Symbol(NonTopLevelEnum.E, Decl(systemModuleNonTopLevelModuleMembers.ts, 10, 33)) +} diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types new file mode 100644 index 00000000000..ffe3d23f7a6 --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts === + +export class TopLevelClass {} +>TopLevelClass : TopLevelClass + +export module TopLevelModule {var v;} +>TopLevelModule : typeof TopLevelModule +>v : any + +export function TopLevelFunction(): void {} +>TopLevelFunction : () => void + +export enum TopLevelEnum {E} +>TopLevelEnum : TopLevelEnum +>E : TopLevelEnum + +export module TopLevelModule2 { +>TopLevelModule2 : typeof TopLevelModule2 + + export class NonTopLevelClass {} +>NonTopLevelClass : NonTopLevelClass + + export module NonTopLevelModule {var v;} +>NonTopLevelModule : typeof NonTopLevelModule +>v : any + + export function NonTopLevelFunction(): void {} +>NonTopLevelFunction : () => void + + export enum NonTopLevelEnum {E} +>NonTopLevelEnum : NonTopLevelEnum +>E : NonTopLevelEnum +} diff --git a/tests/cases/compiler/systemModuleDeclarationMerging.ts b/tests/cases/compiler/systemModuleDeclarationMerging.ts new file mode 100644 index 00000000000..45c59c5b5dc --- /dev/null +++ b/tests/cases/compiler/systemModuleDeclarationMerging.ts @@ -0,0 +1,11 @@ +// @module: system +// @separateCompilation: true + +export function F() {} +export module F { var x; } + +export class C {} +export module C { var x; } + +export enum E {} +export module E { var x; } \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts new file mode 100644 index 00000000000..756d430a2de --- /dev/null +++ b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts @@ -0,0 +1,14 @@ +// @module: system +// @separateCompilation: true + +export class TopLevelClass {} +export module TopLevelModule {var v;} +export function TopLevelFunction(): void {} +export enum TopLevelEnum {E} + +export module TopLevelModule2 { + export class NonTopLevelClass {} + export module NonTopLevelModule {var v;} + export function NonTopLevelFunction(): void {} + export enum NonTopLevelEnum {E} +} \ No newline at end of file From 546330ed7db0700fd3746f019a3f9817f0bef41c Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 11 May 2015 00:09:06 -0700 Subject: [PATCH 10/26] correct typos --- src/compiler/emitter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9c6b4171890..d7996238f4c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2642,7 +2642,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLine(); emitStart(node); - // emit call to exported only for top level nodes + // emit call to exporter only for top level nodes if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) @@ -4420,7 +4420,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { - // write the call to exported for enum + // write the call to exporter for enum writeLine(); write(`${exportFunctionForFile}("`); emitDeclarationName(node); From c828bcb0c7eec0f10a47d1e838aba86a335a90c6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 11 May 2015 14:17:34 -0700 Subject: [PATCH 11/26] addressed PR feedback --- src/compiler/emitter.ts | 19 +++--- .../reference/systemModuleConstEnums.js | 27 ++++++++ .../reference/systemModuleConstEnums.symbols | 35 ++++++++++ .../reference/systemModuleConstEnums.types | 37 ++++++++++ ...stemModuleConstEnumsSeparateCompilation.js | 37 ++++++++++ ...oduleConstEnumsSeparateCompilation.symbols | 35 ++++++++++ ...mModuleConstEnumsSeparateCompilation.types | 37 ++++++++++ .../reference/systemModuleExportDefault.js | 67 +++++++++++++++++++ .../systemModuleExportDefault.symbols | 16 +++++ .../reference/systemModuleExportDefault.types | 16 +++++ .../cases/compiler/systemModuleConstEnums.ts | 13 ++++ ...stemModuleConstEnumsSeparateCompilation.ts | 14 ++++ .../compiler/systemModuleExportDefault.ts | 14 ++++ 13 files changed, 359 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/systemModuleConstEnums.js create mode 100644 tests/baselines/reference/systemModuleConstEnums.symbols create mode 100644 tests/baselines/reference/systemModuleConstEnums.types create mode 100644 tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js create mode 100644 tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols create mode 100644 tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types create mode 100644 tests/baselines/reference/systemModuleExportDefault.js create mode 100644 tests/baselines/reference/systemModuleExportDefault.symbols create mode 100644 tests/baselines/reference/systemModuleExportDefault.types create mode 100644 tests/cases/compiler/systemModuleConstEnums.ts create mode 100644 tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts create mode 100644 tests/cases/compiler/systemModuleExportDefault.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d7996238f4c..71074c53d9c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4377,15 +4377,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return; } - if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); diff --git a/tests/baselines/reference/systemModuleConstEnums.js b/tests/baselines/reference/systemModuleConstEnums.js new file mode 100644 index 00000000000..126e6266b2c --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.js @@ -0,0 +1,27 @@ +//// [systemModuleConstEnums.ts] + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} + +//// [systemModuleConstEnums.js] +System.register([], function(exports_1) { + function foo() { + use(0 /* X */); + use(0 /* X */); + } + exports_1("foo", foo); + return { + setters:[], + execute: function() { + } + } +}); diff --git a/tests/baselines/reference/systemModuleConstEnums.symbols b/tests/baselines/reference/systemModuleConstEnums.symbols new file mode 100644 index 00000000000..171f24628ec --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/systemModuleConstEnums.ts === + +declare function use(a: any); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>a : Symbol(a, Decl(systemModuleConstEnums.ts, 1, 21)) + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnums.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) + +export function foo() { +>foo : Symbol(foo, Decl(systemModuleConstEnums.ts, 2, 34)) + + use(TopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>TopLevelConstEnum.X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnums.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) + + use(M.NonTopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>M.NonTopLevelConstEnum.X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +>M.NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>M : Symbol(M, Decl(systemModuleConstEnums.ts, 7, 1)) +>NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +} + +module M { +>M : Symbol(M, Decl(systemModuleConstEnums.ts, 7, 1)) + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : Symbol(NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>X : Symbol(NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +} diff --git a/tests/baselines/reference/systemModuleConstEnums.types b/tests/baselines/reference/systemModuleConstEnums.types new file mode 100644 index 00000000000..193de0da3ab --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/systemModuleConstEnums.ts === + +declare function use(a: any); +>use : (a: any) => any +>a : any + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : TopLevelConstEnum +>X : TopLevelConstEnum + +export function foo() { +>foo : () => void + + use(TopLevelConstEnum.X); +>use(TopLevelConstEnum.X) : any +>use : (a: any) => any +>TopLevelConstEnum.X : TopLevelConstEnum +>TopLevelConstEnum : typeof TopLevelConstEnum +>X : TopLevelConstEnum + + use(M.NonTopLevelConstEnum.X); +>use(M.NonTopLevelConstEnum.X) : any +>use : (a: any) => any +>M.NonTopLevelConstEnum.X : M.NonTopLevelConstEnum +>M.NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>M : typeof M +>NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>X : M.NonTopLevelConstEnum +} + +module M { +>M : typeof M + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : NonTopLevelConstEnum +>X : NonTopLevelConstEnum +} diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js new file mode 100644 index 00000000000..381331a84db --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js @@ -0,0 +1,37 @@ +//// [systemModuleConstEnumsSeparateCompilation.ts] + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} + +//// [systemModuleConstEnumsSeparateCompilation.js] +System.register([], function(exports_1) { + var TopLevelConstEnum, M; + function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); + } + exports_1("foo", foo); + return { + setters:[], + execute: function() { + (function (TopLevelConstEnum) { + TopLevelConstEnum[TopLevelConstEnum["X"] = 0] = "X"; + })(TopLevelConstEnum || (TopLevelConstEnum = {})); + (function (M) { + (function (NonTopLevelConstEnum) { + NonTopLevelConstEnum[NonTopLevelConstEnum["X"] = 0] = "X"; + })(M.NonTopLevelConstEnum || (M.NonTopLevelConstEnum = {})); + var NonTopLevelConstEnum = M.NonTopLevelConstEnum; + })(M || (M = {})); + } + } +}); diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols new file mode 100644 index 00000000000..d57740b75e9 --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts === + +declare function use(a: any); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>a : Symbol(a, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 21)) + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) + +export function foo() { +>foo : Symbol(foo, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 34)) + + use(TopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>TopLevelConstEnum.X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) + + use(M.NonTopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>M.NonTopLevelConstEnum.X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +>M.NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>M : Symbol(M, Decl(systemModuleConstEnumsSeparateCompilation.ts, 7, 1)) +>NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +} + +module M { +>M : Symbol(M, Decl(systemModuleConstEnumsSeparateCompilation.ts, 7, 1)) + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : Symbol(NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>X : Symbol(NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +} diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types new file mode 100644 index 00000000000..c3a352f66ec --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts === + +declare function use(a: any); +>use : (a: any) => any +>a : any + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : TopLevelConstEnum +>X : TopLevelConstEnum + +export function foo() { +>foo : () => void + + use(TopLevelConstEnum.X); +>use(TopLevelConstEnum.X) : any +>use : (a: any) => any +>TopLevelConstEnum.X : TopLevelConstEnum +>TopLevelConstEnum : typeof TopLevelConstEnum +>X : TopLevelConstEnum + + use(M.NonTopLevelConstEnum.X); +>use(M.NonTopLevelConstEnum.X) : any +>use : (a: any) => any +>M.NonTopLevelConstEnum.X : M.NonTopLevelConstEnum +>M.NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>M : typeof M +>NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>X : M.NonTopLevelConstEnum +} + +module M { +>M : typeof M + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : NonTopLevelConstEnum +>X : NonTopLevelConstEnum +} diff --git a/tests/baselines/reference/systemModuleExportDefault.js b/tests/baselines/reference/systemModuleExportDefault.js new file mode 100644 index 00000000000..4df3ec828c1 --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.js @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/systemModuleExportDefault.ts] //// + +//// [file1.ts] + +export default function() {} + +//// [file2.ts] +export default function foo() {} + +//// [file3.ts] +export default class {} + +//// [file4.ts] +export default class C {} + + + +//// [file1.js] +System.register([], function(exports_1) { + function default_1() { } + exports_1("default", default_1); + return { + setters:[], + execute: function() { + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + function foo() { } + exports_1("default", foo); + return { + setters:[], + execute: function() { + } + } +}); +//// [file3.js] +System.register([], function(exports_1) { + var default_1; + return { + setters:[], + execute: function() { + default_1 = (function () { + function default_1() { + } + return default_1; + })(); + exports_1("default", default_1); + } + } +}); +//// [file4.js] +System.register([], function(exports_1) { + var C; + return { + setters:[], + execute: function() { + C = (function () { + function C() { + } + return C; + })(); + exports_1("default", C); + } + } +}); diff --git a/tests/baselines/reference/systemModuleExportDefault.symbols b/tests/baselines/reference/systemModuleExportDefault.symbols new file mode 100644 index 00000000000..d6e7cde9b71 --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.export default function() {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === +export default function foo() {} +>foo : Symbol(foo, Decl(file2.ts, 0, 0)) + +=== tests/cases/compiler/file3.ts === +export default class {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file4.ts === +export default class C {} +>C : Symbol(C, Decl(file4.ts, 0, 0)) + + diff --git a/tests/baselines/reference/systemModuleExportDefault.types b/tests/baselines/reference/systemModuleExportDefault.types new file mode 100644 index 00000000000..38b5abec8ed --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.export default function() {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === +export default function foo() {} +>foo : () => void + +=== tests/cases/compiler/file3.ts === +export default class {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file4.ts === +export default class C {} +>C : C + + diff --git a/tests/cases/compiler/systemModuleConstEnums.ts b/tests/cases/compiler/systemModuleConstEnums.ts new file mode 100644 index 00000000000..6ad7f31ef91 --- /dev/null +++ b/tests/cases/compiler/systemModuleConstEnums.ts @@ -0,0 +1,13 @@ +// @module: system + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts new file mode 100644 index 00000000000..2fc4707b78e --- /dev/null +++ b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts @@ -0,0 +1,14 @@ +// @module: system +// @separateCompilation: true + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleExportDefault.ts b/tests/cases/compiler/systemModuleExportDefault.ts new file mode 100644 index 00000000000..102c03f0bcd --- /dev/null +++ b/tests/cases/compiler/systemModuleExportDefault.ts @@ -0,0 +1,14 @@ +// @module: system + +// @filename: file1.ts +export default function() {} + +// @filename: file2.ts +export default function foo() {} + +// @filename: file3.ts +export default class {} + +// @filename: file4.ts +export default class C {} + From 409dddc2f3f7c913b1a155c4283a3db1f11e3713 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 10 May 2015 22:23:12 -0700 Subject: [PATCH 12/26] do not hoist ambient declarations --- src/compiler/emitter.ts | 4 + .../systemModuleAmbientDeclarations.js | 84 +++++++++++++++++++ .../systemModuleAmbientDeclarations.symbols | 53 ++++++++++++ .../systemModuleAmbientDeclarations.types | 55 ++++++++++++ .../systemModuleAmbientDeclarations.ts | 28 +++++++ 5 files changed, 224 insertions(+) create mode 100644 tests/baselines/reference/systemModuleAmbientDeclarations.js create mode 100644 tests/baselines/reference/systemModuleAmbientDeclarations.symbols create mode 100644 tests/baselines/reference/systemModuleAmbientDeclarations.types create mode 100644 tests/cases/compiler/systemModuleAmbientDeclarations.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4c979486ff3..38a84af6c05 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5146,6 +5146,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return exportedDeclarations; function visit(node: Node): void { + if (node.flags & NodeFlags.Ambient) { + return; + } + if (node.kind === SyntaxKind.FunctionDeclaration) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.js b/tests/baselines/reference/systemModuleAmbientDeclarations.js new file mode 100644 index 00000000000..82c18cd7981 --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.js @@ -0,0 +1,84 @@ +//// [tests/cases/compiler/systemModuleAmbientDeclarations.ts] //// + +//// [file1.ts] + +declare class Promise { } +declare function Foo(): void; +declare class C {} +declare enum E {X = 1}; + +export var promise = Promise; +export var foo = Foo; +export var c = C; +export var e = E; + +//// [file2.ts] +export declare function foo(); + +//// [file3.ts] +export declare class C {} + +//// [file4.ts] +export declare var v: number; + +//// [file5.ts] +export declare enum E {X = 1} + +//// [file6.ts] +export declare module M { var v: number; } + + +//// [file1.js] +System.register([], function(exports_1) { + var promise, foo, c, e; + return { + setters:[], + execute: function() { + ; + exports_1("promise", promise = Promise); + exports_1("foo", foo = Foo); + exports_1("c", c = C); + exports_1("e", e = E); + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file3.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file4.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file5.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file6.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.symbols b/tests/baselines/reference/systemModuleAmbientDeclarations.symbols new file mode 100644 index 00000000000..c2e8557270b --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/file1.ts === + +declare class Promise { } +>Promise : Symbol(Promise, Decl(file1.ts, 0, 0)) + +declare function Foo(): void; +>Foo : Symbol(Foo, Decl(file1.ts, 1, 25)) + +declare class C {} +>C : Symbol(C, Decl(file1.ts, 2, 29)) + +declare enum E {X = 1}; +>E : Symbol(E, Decl(file1.ts, 3, 18)) +>X : Symbol(E.X, Decl(file1.ts, 4, 16)) + +export var promise = Promise; +>promise : Symbol(promise, Decl(file1.ts, 6, 10)) +>Promise : Symbol(Promise, Decl(file1.ts, 0, 0)) + +export var foo = Foo; +>foo : Symbol(foo, Decl(file1.ts, 7, 10)) +>Foo : Symbol(Foo, Decl(file1.ts, 1, 25)) + +export var c = C; +>c : Symbol(c, Decl(file1.ts, 8, 10)) +>C : Symbol(C, Decl(file1.ts, 2, 29)) + +export var e = E; +>e : Symbol(e, Decl(file1.ts, 9, 10)) +>E : Symbol(E, Decl(file1.ts, 3, 18)) + +=== tests/cases/compiler/file2.ts === +export declare function foo(); +>foo : Symbol(foo, Decl(file2.ts, 0, 0)) + +=== tests/cases/compiler/file3.ts === +export declare class C {} +>C : Symbol(C, Decl(file3.ts, 0, 0)) + +=== tests/cases/compiler/file4.ts === +export declare var v: number; +>v : Symbol(v, Decl(file4.ts, 0, 18)) + +=== tests/cases/compiler/file5.ts === +export declare enum E {X = 1} +>E : Symbol(E, Decl(file5.ts, 0, 0)) +>X : Symbol(E.X, Decl(file5.ts, 0, 23)) + +=== tests/cases/compiler/file6.ts === +export declare module M { var v: number; } +>M : Symbol(M, Decl(file6.ts, 0, 0)) +>v : Symbol(v, Decl(file6.ts, 0, 29)) + diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.types b/tests/baselines/reference/systemModuleAmbientDeclarations.types new file mode 100644 index 00000000000..3633f922881 --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/file1.ts === + +declare class Promise { } +>Promise : Promise + +declare function Foo(): void; +>Foo : () => void + +declare class C {} +>C : C + +declare enum E {X = 1}; +>E : E +>X : E +>1 : number + +export var promise = Promise; +>promise : typeof Promise +>Promise : typeof Promise + +export var foo = Foo; +>foo : () => void +>Foo : () => void + +export var c = C; +>c : typeof C +>C : typeof C + +export var e = E; +>e : typeof E +>E : typeof E + +=== tests/cases/compiler/file2.ts === +export declare function foo(); +>foo : () => any + +=== tests/cases/compiler/file3.ts === +export declare class C {} +>C : C + +=== tests/cases/compiler/file4.ts === +export declare var v: number; +>v : number + +=== tests/cases/compiler/file5.ts === +export declare enum E {X = 1} +>E : E +>X : E +>1 : number + +=== tests/cases/compiler/file6.ts === +export declare module M { var v: number; } +>M : typeof M +>v : number + diff --git a/tests/cases/compiler/systemModuleAmbientDeclarations.ts b/tests/cases/compiler/systemModuleAmbientDeclarations.ts new file mode 100644 index 00000000000..05f78592780 --- /dev/null +++ b/tests/cases/compiler/systemModuleAmbientDeclarations.ts @@ -0,0 +1,28 @@ +// @module: system +// @separateCompilation: true + +// @filename: file1.ts +declare class Promise { } +declare function Foo(): void; +declare class C {} +declare enum E {X = 1}; + +export var promise = Promise; +export var foo = Foo; +export var c = C; +export var e = E; + +// @filename: file2.ts +export declare function foo(); + +// @filename: file3.ts +export declare class C {} + +// @filename: file4.ts +export declare var v: number; + +// @filename: file5.ts +export declare enum E {X = 1} + +// @filename: file6.ts +export declare module M { var v: number; } From fd5dfb63afff41ca1d79e056dbefd99e67a32d9a Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 11 May 2015 14:01:46 -0700 Subject: [PATCH 13/26] program should store file names with normalized slashes --- src/compiler/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3bd4bdc7ac0..4ad82c069c2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -238,7 +238,7 @@ module ts { } function getSourceFile(fileName: string) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(normalizeSlashes(fileName)); return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } @@ -350,7 +350,7 @@ module ts { // Get source file from normalized fileName function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile { - let canonicalName = host.getCanonicalFileName(fileName); + let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName)); if (hasProperty(filesByName, canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); From 2252e3045c84aa5cc1b3900f7a6fae9a6c879929 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 12 May 2015 10:57:55 -0700 Subject: [PATCH 14/26] add optional 'getProjectVersion' method to perform fast up-to-date checks --- src/services/services.ts | 14 ++++++++++++++ src/services/shims.ts | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index bec00b9a66a..4374f3f3ea8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -949,6 +949,7 @@ module ts { export interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; + getProjectVersion?(): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; @@ -2353,6 +2354,7 @@ module ts { let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; let program: Program; + let lastProjectVersion: string; let useCaseSensitivefileNames = false; let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); @@ -2392,6 +2394,18 @@ module ts { } function synchronizeHostData(): void { + // perform fast check if host supports it + if (host.getProjectVersion) { + let hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + + lastProjectVersion = hostProjectVersion; + } + } + // Get a fresh cache of the host information let hostCache = new HostCache(host, getCanonicalFileName); diff --git a/src/services/shims.ts b/src/services/shims.ts index dc19b8eb79b..795058243d9 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -55,6 +55,7 @@ module ts { getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; getNewLine?(): string; + getProjectVersion?(): string; } /** Public interface of the the of a config service shim instance.*/ @@ -260,6 +261,15 @@ module ts { this.shimHost.error(s); } + public getProjectVersion(): string { + if (!this.shimHost.getProjectVersion) { + // shimmed host does not support getProjectVersion + return undefined; + } + + return this.shimHost.getProjectVersion(); + } + public getCompilationSettings(): CompilerOptions { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { From 0b9dd9e2395c682dca2f0c742d6b4099b05d07c7 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 15 May 2015 14:28:02 -0700 Subject: [PATCH 15/26] during file update request only changed portion of the text from the host --- src/services/services.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index bec00b9a66a..08eb1b7521f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1828,7 +1828,34 @@ module ts { if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!disableIncrementalParsing) { - let newSourceFile = updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks); + let newText: string; + + // grab the fragment from the beginning of the original text to the beginning of the span + let prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + + // grab the fragment from the end of the span till the end of the original text + let suffix = textChangeRange.span.start + textChangeRange.span.length !== sourceFile.text.length + ? sourceFile.text.substr(textChangeRange.span.start + textChangeRange.span.length) + : ""; + + if (textChangeRange.newLength === 0) { + // edit was a deletion - just combine prefix and suffix + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + // it was actual edit, fetch the fragment of new text that correspond to new span + let changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + // combine prefix, changed text and suffix + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + + let newSourceFile = updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); setSourceFileFields(newSourceFile, scriptSnapshot, version); // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later From 845820dfe953ce69c98d8aaeef437fff875ccfc0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 15 May 2015 15:28:02 -0700 Subject: [PATCH 16/26] addressed PR feedback --- src/services/services.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 08eb1b7521f..b66ea095ca2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1835,9 +1835,10 @@ module ts { ? sourceFile.text.substr(0, textChangeRange.span.start) : ""; + let textChangeRangeEnd = textChangeRange.span.start + textChangeRange.span.length; // grab the fragment from the end of the span till the end of the original text - let suffix = textChangeRange.span.start + textChangeRange.span.length !== sourceFile.text.length - ? sourceFile.text.substr(textChangeRange.span.start + textChangeRange.span.length) + let suffix = textChangeRangeEnd !== sourceFile.text.length + ? sourceFile.text.substr(textChangeRangeEnd) : ""; if (textChangeRange.newLength === 0) { From 1f35f194d23b7371b2eaa3b7d748211e5a7aad7d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 15 May 2015 16:36:58 -0700 Subject: [PATCH 17/26] use textSpanEnd instead of handrolled version --- src/services/services.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index b66ea095ca2..f70cbd1e79c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1835,11 +1835,10 @@ module ts { ? sourceFile.text.substr(0, textChangeRange.span.start) : ""; - let textChangeRangeEnd = textChangeRange.span.start + textChangeRange.span.length; // grab the fragment from the end of the span till the end of the original text - let suffix = textChangeRangeEnd !== sourceFile.text.length - ? sourceFile.text.substr(textChangeRangeEnd) - : ""; + let suffix = textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(textSpanEnd(textChangeRange.span)) + : ""; if (textChangeRange.newLength === 0) { // edit was a deletion - just combine prefix and suffix From 3853489628fc00d341d01ca036625be7bff35cb4 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 19 May 2015 16:25:12 -0700 Subject: [PATCH 18/26] Update version to 1.5.3 for the VS 2015 release --- package.json | 2 +- src/compiler/program.ts | 2 +- src/services/shims.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 88d5db51f72..efa07c72e29 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.5.2", + "version": "1.5.3", "licenses": [ { "type": "Apache License 2.0", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 232a74107f7..32503de2566 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -8,7 +8,7 @@ module ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - export const version = "1.5.2"; + export const version = "1.5.3"; const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; diff --git a/src/services/shims.ts b/src/services/shims.ts index 795058243d9..f5996e1bf04 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -989,4 +989,4 @@ module TypeScript.Services { } /* @internal */ -let toolsVersion = "1.4"; +let toolsVersion = "1.5"; From 635c7038724a415f31da64ec09deb2e5a9cdfe70 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 19 May 2015 18:07:21 -0700 Subject: [PATCH 19/26] Fix issue in the parsing of tsConfig file, this was fixed in master before, but never ported. The realizeDiagnosticS function already returns an array, no need to wrap again. The realizeDiagnostic (no S) function returns a single diagnostic. --- src/services/shims.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index f5996e1bf04..d3f59737538 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -893,7 +893,7 @@ module ts { return { options: configFile.options, files: configFile.fileNames, - errors: [realizeDiagnostics(configFile.errors, '\r\n')] + errors: realizeDiagnostics(configFile.errors, '\r\n') }; }); } From 16d8d9eb0228f77b0715afec1ec9d9bca7cd4ce7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 19 May 2015 16:17:12 -0700 Subject: [PATCH 20/26] Fix for #2971, adds missing logic in checkFunctionExpressionBodies --- src/compiler/checker.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d956ac189a5..d409d1ea2fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10930,6 +10930,7 @@ module ts { break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: + forEach(node.decorators, checkFunctionExpressionBodies); forEach((node).parameters, checkFunctionExpressionBodies); if (isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); @@ -10944,6 +10945,7 @@ module ts { case SyntaxKind.WithStatement: checkFunctionExpressionBodies((node).expression); break; + case SyntaxKind.Decorator: case SyntaxKind.Parameter: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: From e76f920e75f002041e1c53a3fda0fad1bf93c16e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 19 May 2015 22:07:45 -0700 Subject: [PATCH 21/26] Added tests --- .../decoratorChecksFunctionBodies.errors.txt | 21 ++++++++ .../decoratorChecksFunctionBodies.js | 44 +++++++++++++++ ...ratorInstantiateModulesInFunctionBodies.js | 53 +++++++++++++++++++ ...InstantiateModulesInFunctionBodies.symbols | 34 ++++++++++++ ...orInstantiateModulesInFunctionBodies.types | 40 ++++++++++++++ .../class/decoratorChecksFunctionBodies.ts | 16 ++++++ ...ratorInstantiateModulesInFunctionBodies.ts | 22 ++++++++ 7 files changed, 230 insertions(+) create mode 100644 tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt create mode 100644 tests/baselines/reference/decoratorChecksFunctionBodies.js create mode 100644 tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js create mode 100644 tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols create mode 100644 tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types create mode 100644 tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts create mode 100644 tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt b/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt new file mode 100644 index 00000000000..c8166b538fd --- /dev/null +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts(9,14): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. + + +==== tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts (1 errors) ==== + + // from #2971 + function func(s: string): void { + } + + class A { + @(x => { + var a = 3; + func(a); + ~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. + return x; + }) + m() { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.js b/tests/baselines/reference/decoratorChecksFunctionBodies.js new file mode 100644 index 00000000000..020bc775aea --- /dev/null +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.js @@ -0,0 +1,44 @@ +//// [decoratorChecksFunctionBodies.ts] + +// from #2971 +function func(s: string): void { +} + +class A { + @(x => { + var a = 3; + func(a); + return x; + }) + m() { + + } +} + +//// [decoratorChecksFunctionBodies.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); + switch (arguments.length) { + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); + } +}; +// from #2971 +function func(s) { +} +var A = (function () { + function A() { + } + A.prototype.m = function () { + }; + Object.defineProperty(A.prototype, "m", + __decorate([ + (function (x) { + var a = 3; + func(a); + return x; + }) + ], A.prototype, "m", Object.getOwnPropertyDescriptor(A.prototype, "m"))); + return A; +})(); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js new file mode 100644 index 00000000000..313d77fa5ce --- /dev/null +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts] //// + +//// [a.ts] + +// from #3108 +export var test = 'abc'; + +//// [b.ts] +import { test } from './a'; + +function filter(handler: any) { + return function (target: any) { + // ... + }; +} + +class Wat { + @filter(() => test == 'abc') + static whatever() { + // ... + } +} + +//// [a.js] +// from #3108 +exports.test = 'abc'; +//// [b.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); + switch (arguments.length) { + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); + } +}; +var a_1 = require('./a'); +function filter(handler) { + return function (target) { + // ... + }; +} +var Wat = (function () { + function Wat() { + } + Wat.whatever = function () { + // ... + }; + Object.defineProperty(Wat, "whatever", + __decorate([ + filter(function () { return a_1.test == 'abc'; }) + ], Wat, "whatever", Object.getOwnPropertyDescriptor(Wat, "whatever"))); + return Wat; +})(); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols new file mode 100644 index 00000000000..5088e740a57 --- /dev/null +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/decorators/class/a.ts === + +// from #3108 +export var test = 'abc'; +>test : Symbol(test, Decl(a.ts, 2, 10)) + +=== tests/cases/conformance/decorators/class/b.ts === +import { test } from './a'; +>test : Symbol(test, Decl(b.ts, 0, 8)) + +function filter(handler: any) { +>filter : Symbol(filter, Decl(b.ts, 0, 27)) +>handler : Symbol(handler, Decl(b.ts, 2, 16)) + + return function (target: any) { +>target : Symbol(target, Decl(b.ts, 3, 21)) + + // ... + }; +} + +class Wat { +>Wat : Symbol(Wat, Decl(b.ts, 6, 1)) + + @filter(() => test == 'abc') +>filter : Symbol(filter, Decl(b.ts, 0, 27)) +>test : Symbol(test, Decl(b.ts, 0, 8)) + + static whatever() { +>whatever : Symbol(Wat.whatever, Decl(b.ts, 8, 11)) + + // ... + } +} diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types new file mode 100644 index 00000000000..18d993af9bb --- /dev/null +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/decorators/class/a.ts === + +// from #3108 +export var test = 'abc'; +>test : string +>'abc' : string + +=== tests/cases/conformance/decorators/class/b.ts === +import { test } from './a'; +>test : string + +function filter(handler: any) { +>filter : (handler: any) => (target: any) => void +>handler : any + + return function (target: any) { +>function (target: any) { // ... } : (target: any) => void +>target : any + + // ... + }; +} + +class Wat { +>Wat : Wat + + @filter(() => test == 'abc') +>filter(() => test == 'abc') : (target: any) => void +>filter : (handler: any) => (target: any) => void +>() => test == 'abc' : () => boolean +>test == 'abc' : boolean +>test : string +>'abc' : string + + static whatever() { +>whatever : () => void + + // ... + } +} diff --git a/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts new file mode 100644 index 00000000000..31f5fe82551 --- /dev/null +++ b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts @@ -0,0 +1,16 @@ +// @target:es5 + +// from #2971 +function func(s: string): void { +} + +class A { + @(x => { + var a = 3; + func(a); + return x; + }) + m() { + + } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts new file mode 100644 index 00000000000..7fa7ab8dd84 --- /dev/null +++ b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts @@ -0,0 +1,22 @@ +// @target:es5 +// @module:commonjs +// @filename: a.ts + +// from #3108 +export var test = 'abc'; + +// @filename: b.ts +import { test } from './a'; + +function filter(handler: any) { + return function (target: any) { + // ... + }; +} + +class Wat { + @filter(() => test == 'abc') + static whatever() { + // ... + } +} \ No newline at end of file From cfff30914ccedef1b3616c5eb5e6975f38e813ca Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 May 2015 10:24:19 -0700 Subject: [PATCH 22/26] Updated LKG --- bin/lib.core.es6.d.ts | 2 + bin/lib.es6.d.ts | 2 + bin/tsc.js | 208 ++++++++++++++-------- bin/tsserver.js | 290 +++++++++++++++++++----------- bin/typescript.d.ts | 3 +- bin/typescript.js | 343 ++++++++++++++++++++++++------------ bin/typescriptServices.d.ts | 3 +- bin/typescriptServices.js | 343 ++++++++++++++++++++++++------------ 8 files changed, 795 insertions(+), 399 deletions(-) diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 902962cae51..86e2fa3ad70 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -4766,6 +4766,7 @@ interface PromiseLike { * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } /** @@ -4779,6 +4780,7 @@ interface Promise { * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; /** * Attaches a callback for only the rejection of the Promise. diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index f839a3e3a0b..d6ca7245140 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -4766,6 +4766,7 @@ interface PromiseLike { * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } /** @@ -4779,6 +4780,7 @@ interface Promise { * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; /** * Attaches a callback for only the rejection of the Promise. diff --git a/bin/tsc.js b/bin/tsc.js index ba5dd4f1d17..b14bf75a46b 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -431,9 +431,13 @@ var ts; return 3; return 2; } + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } var idx = path.indexOf('://'); - if (idx !== -1) - return idx + 3; + if (idx !== -1) { + return idx + "://".length; + } return 0; } ts.getRootLength = getRootLength; @@ -1079,8 +1083,8 @@ var ts; Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, @@ -1363,11 +1367,11 @@ var ts; Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." }, - Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." }, - Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, - Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, - Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, + Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, + Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, + Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, @@ -4410,7 +4414,7 @@ var ts; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { - return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -9117,7 +9121,7 @@ var ts; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.separateCompilation) || + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); @@ -10427,7 +10431,10 @@ var ts; function getTypeOfAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = getTypeOfSymbol(resolveAlias(symbol)); + var targetSymbol = resolveAlias(symbol); + links.type = targetSymbol.flags & 107455 + ? getTypeOfSymbol(targetSymbol) + : unknownType; } return links.type; } @@ -11441,7 +11448,13 @@ var ts; } return false; } + var removeSubtypesStack = []; function removeSubtypes(types) { + var typeListId = getTypeListId(types); + if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) { + return; + } + removeSubtypesStack.push(typeListId); var i = types.length; while (i > 0) { i--; @@ -11449,6 +11462,7 @@ var ts; types.splice(i, 1); } } + removeSubtypesStack.pop(); } function containsAnyType(types) { for (var _i = 0; _i < types.length; _i++) { @@ -13004,31 +13018,33 @@ var ts; if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } + var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - var targetType = getTypeOfSymbol(prototypeProperty); - if (targetType !== anyType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); - } + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (prototypePropertyType !== anyType) { + targetType = prototypePropertyType; } } - var constructSignatures; - if (rightType.flags & 2048) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + if (!targetType) { + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 32768) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } } - else if (rightType.flags & 32768) { - constructSignatures = getSignaturesOfType(rightType, 1); - } - if (constructSignatures && constructSignatures.length !== 0) { - var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); } - return instanceType; } return type; } @@ -15529,7 +15545,7 @@ var ts; function checkTypeNodeAsExpression(node) { if (node && node.kind === 142) { var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; + var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 | 132 | 258))) { return; } @@ -16362,7 +16378,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { + if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { checkExpressionOrQualifiedName(baseTypeNode.expression); } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); @@ -16706,8 +16722,8 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); - if (compilerOptions.separateCompilation && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); @@ -16779,7 +16795,7 @@ var ts; if (symbol.flags & 512 && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -17106,6 +17122,7 @@ var ts; break; case 135: case 134: + ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); @@ -17120,6 +17137,7 @@ var ts; case 193: checkFunctionExpressionBodies(node.expression); break; + case 131: case 130: case 133: case 132: @@ -17701,7 +17719,7 @@ var ts; } function isAliasResolvedToValue(symbol) { var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.separateCompilation) { + if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); @@ -21259,7 +21277,7 @@ var ts; } return true; } - function emitListWithSpread(elements, multiLine, trailingComma) { + function emitListWithSpread(elements, alwaysCopy, multiLine, trailingComma) { var pos = 0; var group = 0; var length = elements.length; @@ -21275,6 +21293,9 @@ var ts; e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy && e.kind !== 154) { + write(".slice()"); + } } else { var i = pos; @@ -21312,7 +21333,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, (node.flags & 512) !== 0, elements.hasTrailingComma); + emitListWithSpread(elements, true, (node.flags & 512) !== 0, elements.hasTrailingComma); } } function emitObjectLiteralBody(node, numElements) { @@ -21528,7 +21549,7 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.separateCompilation) { + if (compilerOptions.isolatedModules) { return false; } var constantValue = resolver.getConstantValue(node); @@ -21638,7 +21659,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false); + emitListWithSpread(node.arguments, false, false, false); write(")"); } function emitCallExpression(node) { @@ -22266,7 +22287,7 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (compilerOptions.module === 4) { + if (compilerOptions.module === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 256) { write("default"); @@ -23622,21 +23643,23 @@ var ts; } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } function emitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); @@ -23658,7 +23681,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -23669,6 +23692,14 @@ var ts; write(";"); } if (languageVersion < 2 && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -23707,7 +23738,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 2048); @@ -24255,12 +24286,25 @@ var ts; if (hoistedVars) { writeLine(); write("var "); + var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; + var name_21 = local.kind === 65 + ? local + : local.name; + if (name_21) { + var text = ts.unescapeIdentifier(name_21.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206) { + if (local.kind === 202 || local.kind === 206 || local.kind === 205) { emitDeclarationName(local); } else { @@ -24291,6 +24335,9 @@ var ts; } return exportedDeclarations; function visit(node) { + if (node.flags & 2) { + return; + } if (node.kind === 201) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; @@ -24305,24 +24352,35 @@ var ts; hoistedVars.push(node); return; } - if (node.kind === 206 && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === 205) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 206) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); } - hoistedVars.push(node); return; } if (node.kind === 199 || node.kind === 153) { if (shouldHoistVariable(node, false)) { - var name_21 = node.name; - if (name_21.kind === 65) { + var name_22 = node.name; + if (name_22.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_21); + hoistedVars.push(name_22); } else { - ts.forEachChild(name_21, visit); + ts.forEachChild(name_22, visit); } } return; @@ -24636,7 +24694,7 @@ var ts; paramEmitted = true; } } - if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); } @@ -24992,7 +25050,7 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.2"; + ts.version = "1.5.3"; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function findConfigFile(searchPath) { @@ -25168,14 +25226,14 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } function getDiagnosticsHelper(sourceFile, getDiagnostics) { @@ -25266,7 +25324,7 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { - var canonicalName = host.getCanonicalFileName(fileName); + var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (ts.hasProperty(filesByName, canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } @@ -25409,18 +25467,18 @@ var ts; return allFilesBelongToPath; } function verifyCompilerOptions() { - if (options.separateCompilation) { + if (options.isolatedModules) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); } } if (options.inlineSourceMap) { @@ -25450,14 +25508,14 @@ var ts; } var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.separateCompilation) { + if (options.isolatedModules) { if (!options.module && languageVersion < 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { @@ -25636,7 +25694,7 @@ var ts; paramType: ts.Diagnostics.LOCATION }, { - name: "separateCompilation", + name: "isolatedModules", type: "boolean" }, { diff --git a/bin/tsserver.js b/bin/tsserver.js index 2e4f2c16c75..9a67ba6eca6 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -431,9 +431,13 @@ var ts; return 3; return 2; } + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } var idx = path.indexOf('://'); - if (idx !== -1) - return idx + 3; + if (idx !== -1) { + return idx + "://".length; + } return 0; } ts.getRootLength = getRootLength; @@ -1079,8 +1083,8 @@ var ts; Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, @@ -1363,11 +1367,11 @@ var ts; Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." }, - Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." }, - Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, - Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, - Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, + Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, + Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, + Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, @@ -2850,7 +2854,7 @@ var ts; paramType: ts.Diagnostics.LOCATION }, { - name: "separateCompilation", + name: "isolatedModules", type: "boolean" }, { @@ -4281,7 +4285,7 @@ var ts; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { - return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -9501,7 +9505,7 @@ var ts; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.separateCompilation) || + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); @@ -10811,7 +10815,10 @@ var ts; function getTypeOfAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = getTypeOfSymbol(resolveAlias(symbol)); + var targetSymbol = resolveAlias(symbol); + links.type = targetSymbol.flags & 107455 + ? getTypeOfSymbol(targetSymbol) + : unknownType; } return links.type; } @@ -11825,7 +11832,13 @@ var ts; } return false; } + var removeSubtypesStack = []; function removeSubtypes(types) { + var typeListId = getTypeListId(types); + if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) { + return; + } + removeSubtypesStack.push(typeListId); var i = types.length; while (i > 0) { i--; @@ -11833,6 +11846,7 @@ var ts; types.splice(i, 1); } } + removeSubtypesStack.pop(); } function containsAnyType(types) { for (var _i = 0; _i < types.length; _i++) { @@ -13388,31 +13402,33 @@ var ts; if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } + var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - var targetType = getTypeOfSymbol(prototypeProperty); - if (targetType !== anyType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); - } + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (prototypePropertyType !== anyType) { + targetType = prototypePropertyType; } } - var constructSignatures; - if (rightType.flags & 2048) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + if (!targetType) { + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 32768) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } } - else if (rightType.flags & 32768) { - constructSignatures = getSignaturesOfType(rightType, 1); - } - if (constructSignatures && constructSignatures.length !== 0) { - var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); } - return instanceType; } return type; } @@ -15913,7 +15929,7 @@ var ts; function checkTypeNodeAsExpression(node) { if (node && node.kind === 142) { var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; + var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 | 132 | 258))) { return; } @@ -16746,7 +16762,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { + if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { checkExpressionOrQualifiedName(baseTypeNode.expression); } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); @@ -17090,8 +17106,8 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); - if (compilerOptions.separateCompilation && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); @@ -17163,7 +17179,7 @@ var ts; if (symbol.flags & 512 && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -17490,6 +17506,7 @@ var ts; break; case 135: case 134: + ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); @@ -17504,6 +17521,7 @@ var ts; case 193: checkFunctionExpressionBodies(node.expression); break; + case 131: case 130: case 133: case 132: @@ -18085,7 +18103,7 @@ var ts; } function isAliasResolvedToValue(symbol) { var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.separateCompilation) { + if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); @@ -21643,7 +21661,7 @@ var ts; } return true; } - function emitListWithSpread(elements, multiLine, trailingComma) { + function emitListWithSpread(elements, alwaysCopy, multiLine, trailingComma) { var pos = 0; var group = 0; var length = elements.length; @@ -21659,6 +21677,9 @@ var ts; e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy && e.kind !== 154) { + write(".slice()"); + } } else { var i = pos; @@ -21696,7 +21717,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, (node.flags & 512) !== 0, elements.hasTrailingComma); + emitListWithSpread(elements, true, (node.flags & 512) !== 0, elements.hasTrailingComma); } } function emitObjectLiteralBody(node, numElements) { @@ -21912,7 +21933,7 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.separateCompilation) { + if (compilerOptions.isolatedModules) { return false; } var constantValue = resolver.getConstantValue(node); @@ -22022,7 +22043,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false); + emitListWithSpread(node.arguments, false, false, false); write(")"); } function emitCallExpression(node) { @@ -22650,7 +22671,7 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (compilerOptions.module === 4) { + if (compilerOptions.module === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 256) { write("default"); @@ -24006,21 +24027,23 @@ var ts; } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } function emitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); @@ -24042,7 +24065,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -24053,6 +24076,14 @@ var ts; write(";"); } if (languageVersion < 2 && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -24091,7 +24122,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 2048); @@ -24639,12 +24670,25 @@ var ts; if (hoistedVars) { writeLine(); write("var "); + var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; + var name_21 = local.kind === 65 + ? local + : local.name; + if (name_21) { + var text = ts.unescapeIdentifier(name_21.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206) { + if (local.kind === 202 || local.kind === 206 || local.kind === 205) { emitDeclarationName(local); } else { @@ -24675,6 +24719,9 @@ var ts; } return exportedDeclarations; function visit(node) { + if (node.flags & 2) { + return; + } if (node.kind === 201) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; @@ -24689,24 +24736,35 @@ var ts; hoistedVars.push(node); return; } - if (node.kind === 206 && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === 205) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 206) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); } - hoistedVars.push(node); return; } if (node.kind === 199 || node.kind === 153) { if (shouldHoistVariable(node, false)) { - var name_21 = node.name; - if (name_21.kind === 65) { + var name_22 = node.name; + if (name_22.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_21); + hoistedVars.push(name_22); } else { - ts.forEachChild(name_21, visit); + ts.forEachChild(name_22, visit); } } return; @@ -25020,7 +25078,7 @@ var ts; paramEmitted = true; } } - if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); } @@ -25376,7 +25434,7 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.2"; + ts.version = "1.5.3"; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function findConfigFile(searchPath) { @@ -25552,14 +25610,14 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } function getDiagnosticsHelper(sourceFile, getDiagnostics) { @@ -25650,7 +25708,7 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { - var canonicalName = host.getCanonicalFileName(fileName); + var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (ts.hasProperty(filesByName, canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } @@ -25793,18 +25851,18 @@ var ts; return allFilesBelongToPath; } function verifyCompilerOptions() { - if (options.separateCompilation) { + if (options.isolatedModules) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); } } if (options.inlineSourceMap) { @@ -25834,14 +25892,14 @@ var ts; } var languageVersion = options.target || 0; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.separateCompilation) { + if (options.isolatedModules) { if (!options.module && languageVersion < 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { @@ -26402,10 +26460,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_22 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_22); + for (var name_23 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_23); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_23); if (!matches) { continue; } @@ -26416,14 +26474,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_22); + matches = patternMatcher.getMatches(containers, name_23); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_23, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -26753,9 +26811,9 @@ var ts; case 199: case 153: var variableDeclarationNode; - var name_23; + var name_24; if (node.kind === 153) { - name_23 = node.name; + name_24 = node.name; variableDeclarationNode = node; while (variableDeclarationNode && variableDeclarationNode.kind !== 199) { variableDeclarationNode = variableDeclarationNode.parent; @@ -26765,16 +26823,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_23 = node.name; + name_24 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.variableElement); } case 136: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -28766,9 +28824,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_24 in o) { - if (o[name_24] === rule) { - return name_24; + for (var name_25 in o) { + if (o[name_25] === rule) { + return name_25; } } throw new Error("Unknown rule"); @@ -31298,7 +31356,7 @@ var ts; } function transpile(input, compilerOptions, fileName, diagnostics) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); - options.separateCompilation = true; + options.isolatedModules = true; options.allowNonTsExtensions = true; var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); @@ -31339,7 +31397,25 @@ var ts; if (textChangeRange) { if (version !== sourceFile.version) { if (!ts.disableIncrementalParsing) { - var newSourceFile = ts.updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks); + var newText; + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); setSourceFileFields(newSourceFile, scriptSnapshot, version); newSourceFile.nameTable = undefined; return newSourceFile; @@ -31751,6 +31827,7 @@ var ts; var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; + var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { @@ -31780,6 +31857,15 @@ var ts; return ruleProvider; } function synchronizeHostData() { + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } var hostCache = new HostCache(host, getCanonicalFileName); if (programUpToDate()) { return; @@ -32451,10 +32537,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_25 in nameTable) { - if (!allNames[name_25]) { - allNames[name_25] = name_25; - var displayName = getCompletionEntryDisplayName(name_25, target, true); + for (var name_26 in nameTable) { + if (!allNames[name_26]) { + allNames[name_26] = name_26; + var displayName = getCompletionEntryDisplayName(name_26, target, true); if (displayName) { var entry = { name: displayName, @@ -34133,17 +34219,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_26 = node.text; + var name_27 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_26); + var unionProperty = contextualType.getProperty(name_27); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_26); + var symbol = t.getProperty(name_27); if (symbol) { result_4.push(symbol); } @@ -34152,7 +34238,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_26); + var symbol_1 = contextualType.getProperty(name_27); if (symbol_1) { return [symbol_1]; } @@ -34529,10 +34615,10 @@ var ts; var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; + if (!ts.isTrivia(kind)) { + return; + } if (ts.textSpanIntersectsWith(span, start, width)) { - if (!ts.isTrivia(kind)) { - return; - } if (ts.isComment(kind)) { pushClassification(start, width, 1); continue; diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 3e765a33f01..52a5cc8a96e 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -1114,7 +1114,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; - separateCompilation?: boolean; + isolatedModules?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } @@ -1379,6 +1379,7 @@ declare module "typescript" { interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; + getProjectVersion?(): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; diff --git a/bin/typescript.js b/bin/typescript.js index 4a17fb94c2c..940ce1e211f 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -1129,9 +1129,18 @@ var ts; return 3; return 2; } + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } var idx = path.indexOf('://'); - if (idx !== -1) - return idx + 3; + if (idx !== -1) { + return idx + "://".length; + } return 0; } ts.getRootLength = getRootLength; @@ -1822,8 +1831,8 @@ var ts; Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, @@ -2106,11 +2115,11 @@ var ts; Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." }, - Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." }, - Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, - Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, - Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, + Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, + Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, + Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, @@ -5468,7 +5477,7 @@ var ts; if ((isExternalModule(sourceFile) || !compilerOptions.out)) { // 1. in-browser single file compilation scenario // 2. non .js file - return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -11418,7 +11427,7 @@ var ts; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.separateCompilation) || + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); @@ -12945,7 +12954,15 @@ var ts; function getTypeOfAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = getTypeOfSymbol(resolveAlias(symbol)); + var targetSymbol = resolveAlias(symbol); + // It only makes sense to get the type of a value symbol. If the result of resolving + // the alias is not a value, then it has no type. To get the type associated with a + // type symbol, call getDeclaredTypeOfSymbol. + // This check is important because without it, a call to getTypeOfSymbol could end + // up recursively calling getTypeOfAlias, causing a stack overflow. + links.type = targetSymbol.flags & 107455 /* Value */ + ? getTypeOfSymbol(targetSymbol) + : unknownType; } return links.type; } @@ -14021,7 +14038,17 @@ var ts; } return false; } + // Since removeSubtypes checks the subtype relation, and the subtype relation on a union + // may attempt to reduce a union, it is possible that removeSubtypes could be called + // recursively on the same set of types. The removeSubtypesStack is used to track which + // sets of types are currently undergoing subtype reduction. + var removeSubtypesStack = []; function removeSubtypes(types) { + var typeListId = getTypeListId(types); + if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) { + return; + } + removeSubtypesStack.push(typeListId); var i = types.length; while (i > 0) { i--; @@ -14029,6 +14056,7 @@ var ts; types.splice(i, 1); } } + removeSubtypesStack.pop(); } function containsAnyType(types) { for (var _i = 0; _i < types.length; _i++) { @@ -15730,36 +15758,37 @@ var ts; if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } - // Target type is type of prototype property + var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - var targetType = getTypeOfSymbol(prototypeProperty); - if (targetType !== anyType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); - } + // Target type is type of the protoype property + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (prototypePropertyType !== anyType) { + targetType = prototypePropertyType; } } - // Target type is type of construct signature - var constructSignatures; - if (rightType.flags & 2048 /* Interface */) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + if (!targetType) { + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 32768 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } } - else if (rightType.flags & 32768 /* Anonymous */) { - constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); - } - if (constructSignatures && constructSignatures.length !== 0) { - var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - // Pickup type from union types + if (targetType) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); } - return instanceType; } return type; } @@ -18853,7 +18882,7 @@ var ts; // serialize the type metadata. if (node && node.kind === 142 /* TypeReference */) { var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; + var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } @@ -19863,7 +19892,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { + if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { // Check that base type can be evaluated as expression checkExpressionOrQualifiedName(baseTypeNode.expression); } @@ -20232,8 +20261,8 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); - if (compilerOptions.separateCompilation && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } // Spec 2014 - Section 9.3: // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, @@ -20315,7 +20344,7 @@ var ts; if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -20666,6 +20695,7 @@ var ts; break; case 135 /* MethodDeclaration */: case 134 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); @@ -20680,6 +20710,7 @@ var ts; case 193 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; + case 131 /* Decorator */: case 130 /* Parameter */: case 133 /* PropertyDeclaration */: case 132 /* PropertySignature */: @@ -21317,7 +21348,7 @@ var ts; } function isAliasResolvedToValue(symbol) { var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.separateCompilation) { + if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective @@ -25321,7 +25352,7 @@ var ts; } return true; } - function emitListWithSpread(elements, multiLine, trailingComma) { + function emitListWithSpread(elements, alwaysCopy, multiLine, trailingComma) { var pos = 0; var group = 0; var length = elements.length; @@ -25338,6 +25369,9 @@ var ts; e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + write(".slice()"); + } } else { var i = pos; @@ -25375,7 +25409,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, (node.flags & 512 /* MultiLine */) !== 0, + emitListWithSpread(elements, true, (node.flags & 512 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -25627,7 +25661,7 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.separateCompilation) { + if (compilerOptions.isolatedModules) { // do not inline enum values in separate compilation mode return false; } @@ -25747,7 +25781,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false); + emitListWithSpread(node.arguments, false, false, false); write(")"); } function emitCallExpression(node) { @@ -26451,7 +26485,8 @@ var ts; if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); - if (compilerOptions.module === 4 /* System */) { + // emit call to exporter only for top level nodes + if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -28021,22 +28056,25 @@ var ts; } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } function emitEnumDeclaration(node) { // const enums are completely erased during compilation. if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); @@ -28058,7 +28096,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted writeLine(); emitStart(node); write("var "); @@ -28069,6 +28108,15 @@ var ts; write(";"); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -28107,7 +28155,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); @@ -28708,12 +28756,26 @@ var ts; if (hoistedVars) { writeLine(); write("var "); + var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; + var name_21 = local.kind === 65 /* Identifier */ + ? local + : local.name; + if (name_21) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_21.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */) { + if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -28744,6 +28806,9 @@ var ts; } return exportedDeclarations; function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } if (node.kind === 201 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; @@ -28752,31 +28817,41 @@ var ts; return; } if (node.kind === 202 /* ClassDeclaration */) { - // TODO: rename block scoped classes if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 206 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === 205 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 206 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); } - hoistedVars.push(node); return; } if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_21 = node.name; - if (name_21.kind === 65 /* Identifier */) { + var name_22 = node.name; + if (name_22.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_21); + hoistedVars.push(name_22); } else { - ts.forEachChild(name_21, visit); + ts.forEachChild(name_22, visit); } } return; @@ -29180,7 +29255,7 @@ var ts; paramEmitted = true; } } - if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); } @@ -29571,7 +29646,7 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.2"; + ts.version = "1.5.3"; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function findConfigFile(searchPath) { @@ -29755,14 +29830,19 @@ var ts; // Create the emit resolver outside of the "emitTime" tracking code below. That way // any cost associated with it (like type checking) are appropriate associated with // the type-checking counter. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } function getDiagnosticsHelper(sourceFile, getDiagnostics) { @@ -29855,7 +29935,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { - var canonicalName = host.getCanonicalFileName(fileName); + var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (ts.hasProperty(filesByName, canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); @@ -30013,18 +30093,18 @@ var ts; return allFilesBelongToPath; } function verifyCompilerOptions() { - if (options.separateCompilation) { + if (options.isolatedModules) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); } } if (options.inlineSourceMap) { @@ -30055,14 +30135,14 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.separateCompilation) { + if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { @@ -30251,7 +30331,7 @@ var ts; paramType: ts.Diagnostics.LOCATION }, { - name: "separateCompilation", + name: "isolatedModules", type: "boolean" }, { @@ -30684,12 +30764,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_22 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_22); + for (var name_23 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_23); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_23); if (!matches) { continue; } @@ -30702,14 +30782,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_22); + matches = patternMatcher.getMatches(containers, name_23); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_23, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -31092,9 +31172,9 @@ var ts; case 199 /* VariableDeclaration */: case 153 /* BindingElement */: var variableDeclarationNode; - var name_23; + var name_24; if (node.kind === 153 /* BindingElement */) { - name_23 = node.name; + name_24 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration @@ -31106,16 +31186,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_23 = node.name; + name_24 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.variableElement); } case 136 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -33702,9 +33782,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_24 in o) { - if (o[name_24] === rule) { - return name_24; + for (var name_25 in o) { + if (o[name_25] === rule) { + return name_25; } } throw new Error("Unknown rule"); @@ -36592,12 +36672,12 @@ var ts; * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. * Extra compiler options that will unconditionally be used bu this function are: - * - separateCompilation = true + * - isolatedModules = true * - allowNonTsExtensions = true */ function transpile(input, compilerOptions, fileName, diagnostics) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); - options.separateCompilation = true; + options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; // Parse @@ -36648,7 +36728,30 @@ var ts; if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!ts.disableIncrementalParsing) { - var newSourceFile = ts.updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks); + var newText; + // grab the fragment from the beginning of the original text to the beginning of the span + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + // grab the fragment from the end of the span till the end of the original text + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + // edit was a deletion - just combine prefix and suffix + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + // it was actual edit, fetch the fragment of new text that correspond to new span + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + // combine prefix, changed text and suffix + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); setSourceFileFields(newSourceFile, scriptSnapshot, version); // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later @@ -37125,6 +37228,7 @@ var ts; var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; + var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); // Check if the localized messages json is set, otherwise query the host for it @@ -37156,6 +37260,16 @@ var ts; return ruleProvider; } function synchronizeHostData() { + // perform fast check if host supports it + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); // If the program is already up-to-date, we can reuse it @@ -37954,10 +38068,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_25 in nameTable) { - if (!allNames[name_25]) { - allNames[name_25] = name_25; - var displayName = getCompletionEntryDisplayName(name_25, target, true); + for (var name_26 in nameTable) { + if (!allNames[name_26]) { + allNames[name_26] = name_26; + var displayName = getCompletionEntryDisplayName(name_26, target, true); if (displayName) { var entry = { name: displayName, @@ -39839,19 +39953,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_26 = node.text; + var name_27 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_26); + var unionProperty = contextualType.getProperty(name_27); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_26); + var symbol = t.getProperty(name_27); if (symbol) { result_4.push(symbol); } @@ -39860,7 +39974,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_26); + var symbol_1 = contextualType.getProperty(name_27); if (symbol_1) { return [symbol_1]; } @@ -40280,10 +40394,12 @@ var ts; var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; + // The moment we get something that isn't trivia, then stop processing. + if (!ts.isTrivia(kind)) { + return; + } + // Only bother with the trivia if it at least intersects the span of interest. if (ts.textSpanIntersectsWith(span, start, width)) { - if (!ts.isTrivia(kind)) { - return; - } if (ts.isComment(kind)) { // Simple comment. Just add as is. pushClassification(start, width, 1 /* comment */); @@ -41726,6 +41842,13 @@ var ts; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + // shimmed host does not support getProjectVersion + return undefined; + } + return this.shimHost.getProjectVersion(); + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { @@ -42324,4 +42447,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.4"; +var toolsVersion = "1.5"; diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index 3114c56b789..7ccb2c2f27f 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -1114,7 +1114,7 @@ declare module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; - separateCompilation?: boolean; + isolatedModules?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } @@ -1379,6 +1379,7 @@ declare module ts { interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; + getProjectVersion?(): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 4a17fb94c2c..940ce1e211f 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -1129,9 +1129,18 @@ var ts; return 3; return 2; } + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } var idx = path.indexOf('://'); - if (idx !== -1) - return idx + 3; + if (idx !== -1) { + return idx + "://".length; + } return 0; } ts.getRootLength = getRootLength; @@ -1822,8 +1831,8 @@ var ts; Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, @@ -2106,11 +2115,11 @@ var ts; Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." }, - Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." }, - Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, - Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, - Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, + Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, + Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, + Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, @@ -5468,7 +5477,7 @@ var ts; if ((isExternalModule(sourceFile) || !compilerOptions.out)) { // 1. in-browser single file compilation scenario // 2. non .js file - return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -11418,7 +11427,7 @@ var ts; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.separateCompilation) || + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); @@ -12945,7 +12954,15 @@ var ts; function getTypeOfAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = getTypeOfSymbol(resolveAlias(symbol)); + var targetSymbol = resolveAlias(symbol); + // It only makes sense to get the type of a value symbol. If the result of resolving + // the alias is not a value, then it has no type. To get the type associated with a + // type symbol, call getDeclaredTypeOfSymbol. + // This check is important because without it, a call to getTypeOfSymbol could end + // up recursively calling getTypeOfAlias, causing a stack overflow. + links.type = targetSymbol.flags & 107455 /* Value */ + ? getTypeOfSymbol(targetSymbol) + : unknownType; } return links.type; } @@ -14021,7 +14038,17 @@ var ts; } return false; } + // Since removeSubtypes checks the subtype relation, and the subtype relation on a union + // may attempt to reduce a union, it is possible that removeSubtypes could be called + // recursively on the same set of types. The removeSubtypesStack is used to track which + // sets of types are currently undergoing subtype reduction. + var removeSubtypesStack = []; function removeSubtypes(types) { + var typeListId = getTypeListId(types); + if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) { + return; + } + removeSubtypesStack.push(typeListId); var i = types.length; while (i > 0) { i--; @@ -14029,6 +14056,7 @@ var ts; types.splice(i, 1); } } + removeSubtypesStack.pop(); } function containsAnyType(types) { for (var _i = 0; _i < types.length; _i++) { @@ -15730,36 +15758,37 @@ var ts; if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } - // Target type is type of prototype property + var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - var targetType = getTypeOfSymbol(prototypeProperty); - if (targetType !== anyType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); - } + // Target type is type of the protoype property + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (prototypePropertyType !== anyType) { + targetType = prototypePropertyType; } } - // Target type is type of construct signature - var constructSignatures; - if (rightType.flags & 2048 /* Interface */) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + if (!targetType) { + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 32768 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } } - else if (rightType.flags & 32768 /* Anonymous */) { - constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); - } - if (constructSignatures && constructSignatures.length !== 0) { - var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - // Pickup type from union types + if (targetType) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); } - return instanceType; } return type; } @@ -18853,7 +18882,7 @@ var ts; // serialize the type metadata. if (node && node.kind === 142 /* TypeReference */) { var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; + var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } @@ -19863,7 +19892,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { + if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { // Check that base type can be evaluated as expression checkExpressionOrQualifiedName(baseTypeNode.expression); } @@ -20232,8 +20261,8 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); - if (compilerOptions.separateCompilation && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } // Spec 2014 - Section 9.3: // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, @@ -20315,7 +20344,7 @@ var ts; if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -20666,6 +20695,7 @@ var ts; break; case 135 /* MethodDeclaration */: case 134 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); @@ -20680,6 +20710,7 @@ var ts; case 193 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; + case 131 /* Decorator */: case 130 /* Parameter */: case 133 /* PropertyDeclaration */: case 132 /* PropertySignature */: @@ -21317,7 +21348,7 @@ var ts; } function isAliasResolvedToValue(symbol) { var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.separateCompilation) { + if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective @@ -25321,7 +25352,7 @@ var ts; } return true; } - function emitListWithSpread(elements, multiLine, trailingComma) { + function emitListWithSpread(elements, alwaysCopy, multiLine, trailingComma) { var pos = 0; var group = 0; var length = elements.length; @@ -25338,6 +25369,9 @@ var ts; e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + write(".slice()"); + } } else { var i = pos; @@ -25375,7 +25409,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, (node.flags & 512 /* MultiLine */) !== 0, + emitListWithSpread(elements, true, (node.flags & 512 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -25627,7 +25661,7 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.separateCompilation) { + if (compilerOptions.isolatedModules) { // do not inline enum values in separate compilation mode return false; } @@ -25747,7 +25781,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false); + emitListWithSpread(node.arguments, false, false, false); write(")"); } function emitCallExpression(node) { @@ -26451,7 +26485,8 @@ var ts; if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); - if (compilerOptions.module === 4 /* System */) { + // emit call to exporter only for top level nodes + if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -28021,22 +28056,25 @@ var ts; } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } function emitEnumDeclaration(node) { // const enums are completely erased during compilation. if (!shouldEmitEnumDeclaration(node)) { return; } - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); @@ -28058,7 +28096,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted writeLine(); emitStart(node); write("var "); @@ -28069,6 +28108,15 @@ var ts; write(";"); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -28107,7 +28155,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); @@ -28708,12 +28756,26 @@ var ts; if (hoistedVars) { writeLine(); write("var "); + var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; + var name_21 = local.kind === 65 /* Identifier */ + ? local + : local.name; + if (name_21) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_21.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */) { + if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -28744,6 +28806,9 @@ var ts; } return exportedDeclarations; function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } if (node.kind === 201 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; @@ -28752,31 +28817,41 @@ var ts; return; } if (node.kind === 202 /* ClassDeclaration */) { - // TODO: rename block scoped classes if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 206 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === 205 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 206 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); } - hoistedVars.push(node); return; } if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_21 = node.name; - if (name_21.kind === 65 /* Identifier */) { + var name_22 = node.name; + if (name_22.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_21); + hoistedVars.push(name_22); } else { - ts.forEachChild(name_21, visit); + ts.forEachChild(name_22, visit); } } return; @@ -29180,7 +29255,7 @@ var ts; paramEmitted = true; } } - if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); } @@ -29571,7 +29646,7 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.2"; + ts.version = "1.5.3"; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function findConfigFile(searchPath) { @@ -29755,14 +29830,19 @@ var ts; // Create the emit resolver outside of the "emitTime" tracking code below. That way // any cost associated with it (like type checking) are appropriate associated with // the type-checking counter. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } function getDiagnosticsHelper(sourceFile, getDiagnostics) { @@ -29855,7 +29935,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { - var canonicalName = host.getCanonicalFileName(fileName); + var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (ts.hasProperty(filesByName, canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); @@ -30013,18 +30093,18 @@ var ts; return allFilesBelongToPath; } function verifyCompilerOptions() { - if (options.separateCompilation) { + if (options.isolatedModules) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); } } if (options.inlineSourceMap) { @@ -30055,14 +30135,14 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.separateCompilation) { + if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { @@ -30251,7 +30331,7 @@ var ts; paramType: ts.Diagnostics.LOCATION }, { - name: "separateCompilation", + name: "isolatedModules", type: "boolean" }, { @@ -30684,12 +30764,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_22 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_22); + for (var name_23 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_23); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_23); if (!matches) { continue; } @@ -30702,14 +30782,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_22); + matches = patternMatcher.getMatches(containers, name_23); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_23, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -31092,9 +31172,9 @@ var ts; case 199 /* VariableDeclaration */: case 153 /* BindingElement */: var variableDeclarationNode; - var name_23; + var name_24; if (node.kind === 153 /* BindingElement */) { - name_23 = node.name; + name_24 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration @@ -31106,16 +31186,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_23 = node.name; + name_24 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_24), ts.ScriptElementKind.variableElement); } case 136 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -33702,9 +33782,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_24 in o) { - if (o[name_24] === rule) { - return name_24; + for (var name_25 in o) { + if (o[name_25] === rule) { + return name_25; } } throw new Error("Unknown rule"); @@ -36592,12 +36672,12 @@ var ts; * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. * Extra compiler options that will unconditionally be used bu this function are: - * - separateCompilation = true + * - isolatedModules = true * - allowNonTsExtensions = true */ function transpile(input, compilerOptions, fileName, diagnostics) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); - options.separateCompilation = true; + options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; // Parse @@ -36648,7 +36728,30 @@ var ts; if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!ts.disableIncrementalParsing) { - var newSourceFile = ts.updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks); + var newText; + // grab the fragment from the beginning of the original text to the beginning of the span + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + // grab the fragment from the end of the span till the end of the original text + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + // edit was a deletion - just combine prefix and suffix + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + // it was actual edit, fetch the fragment of new text that correspond to new span + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + // combine prefix, changed text and suffix + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); setSourceFileFields(newSourceFile, scriptSnapshot, version); // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later @@ -37125,6 +37228,7 @@ var ts; var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; + var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); // Check if the localized messages json is set, otherwise query the host for it @@ -37156,6 +37260,16 @@ var ts; return ruleProvider; } function synchronizeHostData() { + // perform fast check if host supports it + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); // If the program is already up-to-date, we can reuse it @@ -37954,10 +38068,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_25 in nameTable) { - if (!allNames[name_25]) { - allNames[name_25] = name_25; - var displayName = getCompletionEntryDisplayName(name_25, target, true); + for (var name_26 in nameTable) { + if (!allNames[name_26]) { + allNames[name_26] = name_26; + var displayName = getCompletionEntryDisplayName(name_26, target, true); if (displayName) { var entry = { name: displayName, @@ -39839,19 +39953,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_26 = node.text; + var name_27 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_26); + var unionProperty = contextualType.getProperty(name_27); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_26); + var symbol = t.getProperty(name_27); if (symbol) { result_4.push(symbol); } @@ -39860,7 +39974,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_26); + var symbol_1 = contextualType.getProperty(name_27); if (symbol_1) { return [symbol_1]; } @@ -40280,10 +40394,12 @@ var ts; var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; + // The moment we get something that isn't trivia, then stop processing. + if (!ts.isTrivia(kind)) { + return; + } + // Only bother with the trivia if it at least intersects the span of interest. if (ts.textSpanIntersectsWith(span, start, width)) { - if (!ts.isTrivia(kind)) { - return; - } if (ts.isComment(kind)) { // Simple comment. Just add as is. pushClassification(start, width, 1 /* comment */); @@ -41726,6 +41842,13 @@ var ts; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + // shimmed host does not support getProjectVersion + return undefined; + } + return this.shimHost.getProjectVersion(); + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { @@ -42324,4 +42447,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.4"; +var toolsVersion = "1.5"; From 7887d6e396dea0537206518d3208949df4725f52 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 20 May 2015 12:02:52 -0700 Subject: [PATCH 23/26] Fix testcases for isolated modules. --- tests/cases/compiler/systemModuleAmbientDeclarations.ts | 2 +- .../cases/compiler/systemModuleConstEnumsSeparateCompilation.ts | 2 +- tests/cases/compiler/systemModuleDeclarationMerging.ts | 2 +- tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cases/compiler/systemModuleAmbientDeclarations.ts b/tests/cases/compiler/systemModuleAmbientDeclarations.ts index 05f78592780..690d0c65c13 100644 --- a/tests/cases/compiler/systemModuleAmbientDeclarations.ts +++ b/tests/cases/compiler/systemModuleAmbientDeclarations.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true // @filename: file1.ts declare class Promise { } diff --git a/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts index 2fc4707b78e..3813017639f 100644 --- a/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts +++ b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true declare function use(a: any); const enum TopLevelConstEnum { X } diff --git a/tests/cases/compiler/systemModuleDeclarationMerging.ts b/tests/cases/compiler/systemModuleDeclarationMerging.ts index 45c59c5b5dc..ae8b3a8dd0b 100644 --- a/tests/cases/compiler/systemModuleDeclarationMerging.ts +++ b/tests/cases/compiler/systemModuleDeclarationMerging.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true export function F() {} export module F { var x; } diff --git a/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts index 756d430a2de..b5617970339 100644 --- a/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts +++ b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts @@ -1,5 +1,5 @@ // @module: system -// @separateCompilation: true +// @isolatedModules: true export class TopLevelClass {} export module TopLevelModule {var v;} From 711886e09994eda5bafa9383d92954242fc342c5 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 20 May 2015 13:44:02 -0700 Subject: [PATCH 24/26] update LKG --- bin/typescript.js | 2 +- bin/typescriptServices.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/typescript.js b/bin/typescript.js index 940ce1e211f..5f1053a72bd 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -42361,7 +42361,7 @@ var ts; return { options: configFile.options, files: configFile.fileNames, - errors: [realizeDiagnostics(configFile.errors, '\r\n')] + errors: realizeDiagnostics(configFile.errors, '\r\n') }; }); }; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 940ce1e211f..5f1053a72bd 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -42361,7 +42361,7 @@ var ts; return { options: configFile.options, files: configFile.fileNames, - errors: [realizeDiagnostics(configFile.errors, '\r\n')] + errors: realizeDiagnostics(configFile.errors, '\r\n') }; }); }; From 62ba36908bceed22a52cee3269223189397cbab5 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 1 Jun 2015 15:01:24 -0700 Subject: [PATCH 25/26] Added experimentalDecorators flag --- src/compiler/checker.ts | 4 ++++ src/compiler/commandLineParser.ts | 8 +++++++- .../diagnosticInformationMap.generated.ts | 4 ++++ src/compiler/diagnosticMessages.json | 17 ++++++++++++++++- src/compiler/program.ts | 5 +++++ src/compiler/types.ts | 1 + src/harness/harness.ts | 6 +++++- .../compiler/classExpressionWithDecorator1.ts | 1 + tests/cases/compiler/noEmitHelpers2.ts | 1 + .../compiler/sourceMapValidationDecorators.ts | 1 + .../class/accessor/decoratorOnClassAccessor1.ts | 1 + .../class/accessor/decoratorOnClassAccessor2.ts | 1 + .../class/accessor/decoratorOnClassAccessor3.ts | 1 + .../class/accessor/decoratorOnClassAccessor4.ts | 1 + .../class/accessor/decoratorOnClassAccessor5.ts | 1 + .../class/accessor/decoratorOnClassAccessor6.ts | 1 + .../constructor/decoratorOnClassConstructor1.ts | 1 + .../decoratorOnClassConstructorParameter1.ts | 1 + .../decoratorOnClassConstructorParameter4.ts | 1 + .../class/decoratedClassFromExternalModule.ts | 1 + .../class/decoratorChecksFunctionBodies.ts | 1 + ...coratorInstantiateModulesInFunctionBodies.ts | 1 + .../decorators/class/decoratorOnClass1.ts | 1 + .../decorators/class/decoratorOnClass2.ts | 1 + .../decorators/class/decoratorOnClass3.ts | 1 + .../decorators/class/decoratorOnClass4.ts | 1 + .../decorators/class/decoratorOnClass5.ts | 1 + .../decorators/class/decoratorOnClass8.ts | 1 + .../class/method/decoratorOnClassMethod1.ts | 1 + .../class/method/decoratorOnClassMethod10.ts | 1 + .../class/method/decoratorOnClassMethod11.ts | 1 + .../class/method/decoratorOnClassMethod12.ts | 1 + .../class/method/decoratorOnClassMethod13.ts | 1 + .../class/method/decoratorOnClassMethod2.ts | 1 + .../class/method/decoratorOnClassMethod3.ts | 1 + .../class/method/decoratorOnClassMethod4.ts | 1 + .../class/method/decoratorOnClassMethod5.ts | 1 + .../class/method/decoratorOnClassMethod6.ts | 1 + .../class/method/decoratorOnClassMethod7.ts | 1 + .../class/method/decoratorOnClassMethod8.ts | 1 + .../decoratorOnClassMethodParameter1.ts | 1 + .../class/property/decoratorOnClassProperty1.ts | 1 + .../property/decoratorOnClassProperty10.ts | 1 + .../property/decoratorOnClassProperty11.ts | 1 + .../class/property/decoratorOnClassProperty2.ts | 1 + .../class/property/decoratorOnClassProperty3.ts | 1 + .../class/property/decoratorOnClassProperty6.ts | 1 + .../class/property/decoratorOnClassProperty7.ts | 1 + .../decorators/missingDecoratorType.ts | 6 +++--- 49 files changed, 86 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d409d1ea2fa..85cde0c9551 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8942,6 +8942,10 @@ module ts { if (!nodeCanBeDecorated(node)) { return; } + + if (!compilerOptions.experimentalDecorators) { + error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 64784590024..351f1caec94 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -188,10 +188,16 @@ module ts { type: "boolean", description: Diagnostics.Watch_input_files, }, + { + name: "experimentalDecorators", + type: "boolean", + description: Diagnostics.Enables_experimental_support_for_ES7_decorators + }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true + experimental: true, + description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators } ]; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 8dd6ea6dc55..a42ce1b2338 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -174,6 +174,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -507,6 +508,9 @@ module ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 416936e741b..0ad8fc68528 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -683,6 +683,10 @@ "category": "Error", "code": 1218 }, + "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { + "category": "Error", + "code": 1219 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -2018,7 +2022,18 @@ "category": "Error", "code": 6062 }, - + "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { + "category": "Error", + "code": 6064 + }, + "Enables experimental support for ES7 decorators.": { + "category": "Message", + "code": 6065 + }, + "Enables experimental support for emitting type metadata for decorators.": { + "category": "Message", + "code": 6066 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 32503de2566..9e0e250c987 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -635,6 +635,11 @@ module ts { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } + + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + } } } } \ No newline at end of file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6fa89846bb..848b51d721b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1677,6 +1677,7 @@ module ts { version?: boolean; watch?: boolean; isolatedModules?: boolean; + experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; [option: string]: string | number | boolean; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 63eff36b30a..f64fa57a41a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -998,6 +998,10 @@ module Harness { options.target = setting.value; } break; + + case 'experimentaldecorators': + options.experimentalDecorators = setting.value === 'true'; + break; case 'emitdecoratormetadata': options.emitDecoratorMetadata = setting.value === 'true'; @@ -1510,7 +1514,7 @@ module Harness { "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources", "emitdecoratormetadata"]; + "inlinesources", "emitdecoratormetadata", "experimentaldecorators"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/tests/cases/compiler/classExpressionWithDecorator1.ts b/tests/cases/compiler/classExpressionWithDecorator1.ts index 74b49456a36..67e9c8aa6ce 100644 --- a/tests/cases/compiler/classExpressionWithDecorator1.ts +++ b/tests/cases/compiler/classExpressionWithDecorator1.ts @@ -1 +1,2 @@ +// @experimentaldecorators: true var v = @decorate class C { static p = 1 }; \ No newline at end of file diff --git a/tests/cases/compiler/noEmitHelpers2.ts b/tests/cases/compiler/noEmitHelpers2.ts index df71f4fae82..ccc17f7066e 100644 --- a/tests/cases/compiler/noEmitHelpers2.ts +++ b/tests/cases/compiler/noEmitHelpers2.ts @@ -1,4 +1,5 @@ // @noemithelpers: true +// @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 diff --git a/tests/cases/compiler/sourceMapValidationDecorators.ts b/tests/cases/compiler/sourceMapValidationDecorators.ts index c8bd16be80f..898d3f729b2 100644 --- a/tests/cases/compiler/sourceMapValidationDecorators.ts +++ b/tests/cases/compiler/sourceMapValidationDecorators.ts @@ -1,5 +1,6 @@ // @sourcemap: true // @target: es5 +// @experimentaldecorators: true declare function ClassDecorator1(target: Function): void; declare function ClassDecorator2(x: number): (target: Function) => void; declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts index 7e80e9e637d..19abd8231d6 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts index bbe58e72eb9..5250b42929c 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts index bd1ce41bb12..4d7ccc6a825 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts index 72259e5d212..35c15ae7a6f 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts index ba5f82ab0ce..b32dd98ed2a 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts index 686127858b0..ffbd2713621 100644 --- a/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts +++ b/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts b/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts index 4a39536e30b..b9ee9295744 100644 --- a/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts +++ b/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts b/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts index 3f4baabac7c..dbfd38c7896 100644 --- a/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts +++ b/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; class C { diff --git a/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts b/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts index e58771fbebb..4e0373ff5d1 100644 --- a/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts +++ b/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; class C { diff --git a/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts b/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts index cb622265b44..95f8bf4ab97 100644 --- a/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts +++ b/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts @@ -1,4 +1,5 @@ // @target: es6 +// @experimentaldecorators: true // @Filename: decorated.ts function decorate() { } diff --git a/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts index 31f5fe82551..b1cbd1a679c 100644 --- a/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts +++ b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true // from #2971 function func(s: string): void { diff --git a/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts index 7fa7ab8dd84..9163ed0c384 100644 --- a/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts +++ b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts @@ -1,5 +1,6 @@ // @target:es5 // @module:commonjs +// @experimentaldecorators: true // @filename: a.ts // from #3108 diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass1.ts b/tests/cases/conformance/decorators/class/decoratorOnClass1.ts index 1d3c87e7a6a..c1a729f56f3 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass1.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass1.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: T): T; @dec diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass2.ts b/tests/cases/conformance/decorators/class/decoratorOnClass2.ts index c82b9fe04a7..062ef391205 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass2.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass2.ts @@ -1,5 +1,6 @@ // @target:es5 // @module: commonjs +// @experimentaldecorators: true declare function dec(target: T): T; @dec diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass3.ts b/tests/cases/conformance/decorators/class/decoratorOnClass3.ts index cf778380356..e410eaa1b07 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass3.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass3.ts @@ -1,5 +1,6 @@ // @target:es5 // @module: commonjs +// @experimentaldecorators: true declare function dec(target: T): T; export diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass4.ts b/tests/cases/conformance/decorators/class/decoratorOnClass4.ts index e365df091fc..bebf595a170 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass4.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass4.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(): (target: T) => T; @dec() diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass5.ts b/tests/cases/conformance/decorators/class/decoratorOnClass5.ts index e365df091fc..bebf595a170 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass5.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass5.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(): (target: T) => T; @dec() diff --git a/tests/cases/conformance/decorators/class/decoratorOnClass8.ts b/tests/cases/conformance/decorators/class/decoratorOnClass8.ts index a7227964180..bade386a56b 100644 --- a/tests/cases/conformance/decorators/class/decoratorOnClass8.ts +++ b/tests/cases/conformance/decorators/class/decoratorOnClass8.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(): (target: Function, paramIndex: number) => void; @dec() diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts index 7216be210f1..418ace9a0dc 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts index 03f75f16552..c4658cc6405 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: Function, paramIndex: number): void; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts index 6f80fa00bca..058f8134880 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true module M { class C { decorator(target: Object, key: string): void { } diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts index a9a2607c39b..9af80e32c46 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true module M { class S { decorator(target: Object, key: string): void { } diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts index df0b847e99d..f41481d4ad0 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentaldecorators: true declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts index 7b7f089e4d4..8305ed1a448 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts index aa80151cf83..b951bd5c8c9 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts index 92b35ae6189..3d3ff2c8785 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts index cd891b4231b..d91d4331ce0 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentaldecorators: true declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts index a1fa7005892..b3cd6ee75d4 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentaldecorators: true declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts index 4bf86aa4995..16915e9aaab 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts index 9bd2c192c2d..73f58809420 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: T): T; class C { diff --git a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts index e525933fb6a..18a7fff6dd0 100644 --- a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts +++ b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts @@ -1,4 +1,5 @@ // @target:es5 +// @experimentaldecorators: true declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts index 0d8fd82225d..026949fb5b8 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string): void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts index 4be77035692..2b10c0aec08 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(): (target: any, propertyKey: string) => void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts index 60ea10189e2..eb720b20dff 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(): (target: any, propertyKey: string) => void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts index dc2886e7dbd..01af3e6ee81 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string): void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts index cf58b4b71ec..55fd6fe93e1 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: any, propertyKey: string): void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts index 1dd184419af..412a592ece1 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: Function): void; class C { diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts index d82ca6eb2eb..0e11e103ce7 100644 --- a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts @@ -1,4 +1,5 @@ // @target: ES5 +// @experimentaldecorators: true declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void; class C { diff --git a/tests/cases/conformance/decorators/missingDecoratorType.ts b/tests/cases/conformance/decorators/missingDecoratorType.ts index 1407e00b7a3..905edaf0756 100644 --- a/tests/cases/conformance/decorators/missingDecoratorType.ts +++ b/tests/cases/conformance/decorators/missingDecoratorType.ts @@ -1,4 +1,5 @@ -// @target: ES5 +// @target: ES5 +// @experimentaldecorators: true // @noLib: true // @Filename: a.ts @@ -11,8 +12,7 @@ interface Function { } interface RegExp { } interface IArguments { } -// @Filename: b.ts -/// +// @Filename: b.ts declare var dec: any; @dec From 69094b5693656c2a230875532b9a20caeb1d0013 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 1 Jun 2015 15:35:42 -0700 Subject: [PATCH 26/26] Updated LKG --- bin/tsc.js | 19 ++++++++++++++++++- bin/tsserver.js | 19 ++++++++++++++++++- bin/typescript.d.ts | 1 + bin/typescript.js | 19 ++++++++++++++++++- bin/typescriptServices.d.ts | 1 + bin/typescriptServices.js | 19 ++++++++++++++++++- 6 files changed, 74 insertions(+), 4 deletions(-) diff --git a/bin/tsc.js b/bin/tsc.js index b14bf75a46b..8c1542d6c7b 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -1092,6 +1092,7 @@ var ts; Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1425,6 +1426,9 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -15586,6 +15590,9 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return; } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { case 202: @@ -25547,6 +25554,10 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + } } } ts.createProgram = createProgram; @@ -25740,10 +25751,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators } ]; function parseCommandLine(commandLine) { diff --git a/bin/tsserver.js b/bin/tsserver.js index 9a67ba6eca6..4f175eee95b 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -1092,6 +1092,7 @@ var ts; Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1425,6 +1426,9 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2900,10 +2904,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators } ]; function parseCommandLine(commandLine) { @@ -15970,6 +15980,9 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return; } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { case 202: @@ -25931,6 +25944,10 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + } } } ts.createProgram = createProgram; diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 52a5cc8a96e..50f5c1ade22 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -1115,6 +1115,7 @@ declare module "typescript" { version?: boolean; watch?: boolean; isolatedModules?: boolean; + experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } diff --git a/bin/typescript.js b/bin/typescript.js index 5f1053a72bd..a60814cc7fd 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -1840,6 +1840,7 @@ var ts; Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2173,6 +2174,9 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -18932,6 +18936,9 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return; } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { @@ -30183,6 +30190,10 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + } } } ts.createProgram = createProgram; @@ -30377,10 +30388,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators } ]; function parseCommandLine(commandLine) { diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index 7ccb2c2f27f..558504fcede 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -1115,6 +1115,7 @@ declare module ts { version?: boolean; watch?: boolean; isolatedModules?: boolean; + experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 5f1053a72bd..a60814cc7fd 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -1840,6 +1840,7 @@ var ts; Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2173,6 +2174,9 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -18932,6 +18936,9 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return; } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { @@ -30183,6 +30190,10 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + } } } ts.createProgram = createProgram; @@ -30377,10 +30388,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators } ]; function parseCommandLine(commandLine) {