diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 699d2f74a6473..f59aaa6449726 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -713,8 +713,14 @@ module ts { function markExportAsReferenced(node: ImportEqualsDeclaration | ExportAssignment | ExportSpecifier) { let symbol = getSymbolOfNode(node); let target = resolveAlias(symbol); - if (target && target !== unknownSymbol && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target)) { - markAliasSymbolAsReferenced(symbol); + if (target) { + let markAlias = + (target === unknownSymbol && compilerOptions.separateCompilation) || + (target !== unknownSymbol && (target.flags & SymbolFlags.Value) && !isConstEnumOrConstEnumOnlyModule(target)); + + if (markAlias) { + markAliasSymbolAsReferenced(symbol); + } } } @@ -9747,7 +9753,9 @@ module ts { checkKindsOfPropertyMemberOverrides(type, baseType); } + } + if (type.baseTypes.length || (baseTypeNode && compilerOptions.separateCompilation)) { // Check that base type can be evaluated as expression checkExpressionOrQualifiedName(baseTypeNode.typeName); } @@ -10151,6 +10159,11 @@ 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); + } + // Spec 2014 - Section 9.3: // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, // and when an enum type has multiple declarations, only one declaration is permitted to omit a value @@ -10161,7 +10174,6 @@ module ts { let firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { - let enumIsConst = isConst(node); // check that const is placed\omitted on all enum declarations forEach(enumSymbol.declarations, decl => { if (isConstEnumDeclaration(decl) !== enumIsConst) { @@ -10223,7 +10235,7 @@ module ts { if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node) - && isInstantiatedModule(node, compilerOptions.preserveConstEnums)) { + && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) { let classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) { @@ -11266,13 +11278,18 @@ module ts { // parent is not source file or it is not reference to internal module return false; } - return isAliasResolvedToValue(getSymbolOfNode(node)); + + var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + return isValue && node.moduleReference && !nodeIsMissing(node.moduleReference); } function isAliasResolvedToValue(symbol: Symbol): boolean { let target = resolveAlias(symbol); + if (target === unknownSymbol && compilerOptions.separateCompilation) { + return true; + } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && target && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target); } function isConstEnumOrConstEnumOnlyModule(s: Symbol): boolean { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 96c1bc9e296fd..29c2c6452dbba 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -109,6 +109,10 @@ module ts { type: "boolean", description: Diagnostics.Do_not_emit_comments_to_output, }, + { + name: "separateCompilation", + type: "boolean", + }, { name: "sourceMap", type: "boolean", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 967afd171bac8..32d36020d3d70 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -165,6 +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_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules 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." }, 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." }, @@ -434,6 +436,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." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6e24afad80c4a..f593ac2ff70b3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -651,7 +651,14 @@ "category": "Error", "code": 1207 }, - + "Cannot compile non-external modules when the '--separateCompilation' flag is provided.": { + "category": "Error", + "code": 1208 + }, + "Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": { + "category": "Error", + "code": 1209 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -1729,6 +1736,26 @@ "category": "Error", "code": 5042 }, + "Option 'sourceMap' cannot be specified with option 'separateCompilation'.": { + "category": "Error", + "code": 5043 + }, + "Option 'declaration' cannot be specified with option 'separateCompilation'.": { + "category": "Error", + "code": 5044 + }, + "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": { + "category": "Error", + "code": 5045 + }, + "Option 'out' cannot be specified with option 'separateCompilation'.": { + "category": "Error", + "code": 5046 + }, + "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { + "category": "Error", + "code": 5047 + }, "Concatenate and emit output to single file.": { "category": "Message", "code": 6001 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ac5fa31319f82..3ed3cb8e64dd8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1641,6 +1641,11 @@ module ts { } function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { + if (compilerOptions.separateCompilation) { + // do not inline enum values in separate compilation mode + return false; + } + let constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { write(constantValue.toString()); @@ -3872,7 +3877,7 @@ module ts { function shouldEmitEnumDeclaration(node: EnumDeclaration) { let isConstEnum = isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums; + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; } function emitEnumDeclaration(node: EnumDeclaration) { @@ -3964,7 +3969,7 @@ module ts { } function shouldEmitModuleDeclaration(node: ModuleDeclaration) { - return isInstantiatedModule(node, compilerOptions.preserveConstEnums); + return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); } function emitModuleDeclaration(node: ModuleDeclaration) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 63847dec515e5..69faeda2db059 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -454,6 +454,24 @@ module ts { } function verifyCompilerOptions() { + if (options.separateCompilation) { + if (options.sourceMap) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation)); + } + + if (options.declaration) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation)); + } + + if (options.noEmitOnError) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation)); + } + + if (options.out) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); + } + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { @@ -468,12 +486,21 @@ module ts { let languageVersion = options.target || ScriptTarget.ES3; let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); - if (firstExternalModuleSourceFile && !options.module) { + if (options.separateCompilation) { if (!options.module && languageVersion < ScriptTarget.ES6) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet - let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_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_non_external_modules_when_the_separateCompilation_flag_is_provided)); + } + } + else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { + // We cannot use createDiagnosticFromNode because nodes do not have parents yet + let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above @@ -481,11 +508,11 @@ module ts { diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } - // there has to be common source directory if user specified --outdir || --sourcRoot + // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified options.sourceRoot || // there is --sourceRoot specified - (options.mapRoot && // there is --mapRoot Specified and there would be multiple js files generated + (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated (!options.out || firstExternalModuleSourceFile !== undefined))) { let commonPathComponents: string[]; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 56d5b0a7e1820..8992a6fbd940a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1585,6 +1585,7 @@ module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; + separateCompilation?: boolean; /* @internal */ stripInternal?: boolean; [option: string]: string | number | boolean; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9fa0674c25c07..936d40e18d320 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -274,6 +274,13 @@ module ts { export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan { let errorNode = node; switch (node.kind) { + case SyntaxKind.SourceFile: + let pos = skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); + if (pos === sourceFile.text.length) { + // file is empty - return span for the beginning of the file + return createTextSpan(0, 0); + } + return getSpanOfTokenAtPosition(sourceFile, pos); // This list is a work in progress. Add missing node kinds to improve their error // spans. case SyntaxKind.VariableDeclaration: diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 40bf68f0a3d04..b9a08d6e982ad 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1052,6 +1052,10 @@ module Harness { options.preserveConstEnums = setting.value === 'true'; break; + case 'separatecompilation': + options.separateCompilation = setting.value === 'true'; + break; + case 'suppressimplicitanyindexerrors': options.suppressImplicitAnyIndexErrors = setting.value === 'true'; break; @@ -1451,7 +1455,12 @@ module Harness { var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"]; + var fileMetadataNames = ["filename", "comments", "declaration", "module", + "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", + "noimplicitany", "noresolve", "newline", "newlines", "emitbom", + "errortruncation", "usecasesensitivefilenames", "preserveconstenums", + "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "separatecompilation"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/src/services/services.ts b/src/services/services.ts index fa419cf9f104a..e33dc132f9447 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1635,6 +1635,61 @@ module ts { sourceFile.scriptSnapshot = scriptSnapshot; } + /* + * 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 + * - allowNonTsExtensions = true + */ + export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string { + let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions(); + + options.separateCompilation = true; + + // Filename can be non-ts file. + options.allowNonTsExtensions = true; + + // Parse + var inputFileName = fileName || "module.ts"; + var sourceFile = createSourceFile(inputFileName, input, options.target); + + // Store syntactic diagnostics + if (diagnostics && sourceFile.parseDiagnostics) { + diagnostics.push(...sourceFile.parseDiagnostics); + } + + // Output + let outputText: string; + + // Create a compilerHost object to allow the compiler to read and write files + var compilerHost: CompilerHost = { + getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, + writeFile: (name, text, writeByteOrderMark) => { + Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + }, + getDefaultLibFileName: () => "lib.d.ts", + useCaseSensitiveFileNames: () => false, + getCanonicalFileName: fileName => fileName, + getCurrentDirectory: () => "", + getNewLine: () => "\r\n" + }; + + var program = createProgram([inputFileName], options, compilerHost); + + if (diagnostics) { + diagnostics.push(...program.getGlobalDiagnostics()); + } + + // Emit + program.emit(); + + Debug.assert(outputText !== undefined, "Output generation failed"); + + return outputText; + } + export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile { let sourceFile = createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents); setSourceFileFields(sourceFile, scriptSnapshot, version); diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 397404ee98c94..2f40779fbdd56 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1241,6 +1241,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + separateCompilation?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1982,6 +1983,7 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index b23ab38e0c743..79d1a43106ac0 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -3978,6 +3978,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + separateCompilation?: boolean; +>separateCompilation : boolean + [option: string]: string | number | boolean; >option : string } @@ -6154,6 +6157,15 @@ declare module "typescript" { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; +>transpile : (input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]) => string +>input : string +>compilerOptions : CompilerOptions +>CompilerOptions : CompilerOptions +>fileName : string +>diagnostics : Diagnostic[] +>Diagnostic : Diagnostic + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; >createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile >fileName : string diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index fc8f844ac0048..16930187a6490 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1272,6 +1272,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + separateCompilation?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -2013,6 +2014,7 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 64e4910853fe6..991f7294fefff 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -4124,6 +4124,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + separateCompilation?: boolean; +>separateCompilation : boolean + [option: string]: string | number | boolean; >option : string } @@ -6300,6 +6303,15 @@ declare module "typescript" { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; +>transpile : (input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]) => string +>input : string +>compilerOptions : CompilerOptions +>CompilerOptions : CompilerOptions +>fileName : string +>diagnostics : Diagnostic[] +>Diagnostic : Diagnostic + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; >createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile >fileName : string diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 77c772781156e..3732093cfe2be 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1273,6 +1273,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + separateCompilation?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -2014,6 +2015,7 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 7a284e2026da8..fedee04b0d04d 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -4074,6 +4074,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + separateCompilation?: boolean; +>separateCompilation : boolean + [option: string]: string | number | boolean; >option : string } @@ -6250,6 +6253,15 @@ declare module "typescript" { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; +>transpile : (input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]) => string +>input : string +>compilerOptions : CompilerOptions +>CompilerOptions : CompilerOptions +>fileName : string +>diagnostics : Diagnostic[] +>Diagnostic : Diagnostic + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; >createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile >fileName : string diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 8340a5150c9ab..7ca1b872f503c 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1310,6 +1310,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + separateCompilation?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -2051,6 +2052,7 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index d151e8f046b29..83ab4a43645f0 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -4247,6 +4247,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + separateCompilation?: boolean; +>separateCompilation : boolean + [option: string]: string | number | boolean; >option : string } @@ -6423,6 +6426,15 @@ declare module "typescript" { throwIfCancellationRequested(): void; >throwIfCancellationRequested : () => void } + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; +>transpile : (input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]) => string +>input : string +>compilerOptions : CompilerOptions +>CompilerOptions : CompilerOptions +>fileName : string +>diagnostics : Diagnostic[] +>Diagnostic : Diagnostic + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; >createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile >fileName : string diff --git a/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt b/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt new file mode 100644 index 0000000000000..6ea2e445e294a --- /dev/null +++ b/tests/baselines/reference/separateCompilationAmbientConstEnum.errors.txt @@ -0,0 +1,10 @@ +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 (1 errors) ==== + + + declare const enum E { X = 1} + ~ +!!! error TS1209: Ambient const enums are not allowed when the '--separateCompilation' 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 new file mode 100644 index 0000000000000..5b3af0957e74c --- /dev/null +++ b/tests/baselines/reference/separateCompilationAmbientConstEnum.js @@ -0,0 +1,8 @@ +//// [separateCompilationAmbientConstEnum.ts] + + +declare const enum E { X = 1} +export var y; + +//// [separateCompilationAmbientConstEnum.js] +export var y; diff --git a/tests/baselines/reference/separateCompilationDeclaration.errors.txt b/tests/baselines/reference/separateCompilationDeclaration.errors.txt new file mode 100644 index 0000000000000..8951184584c18 --- /dev/null +++ b/tests/baselines/reference/separateCompilationDeclaration.errors.txt @@ -0,0 +1,7 @@ +error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'. + + +!!! error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'. +==== tests/cases/compiler/separateCompilationDeclaration.ts (0 errors) ==== + + export var x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationDeclaration.js b/tests/baselines/reference/separateCompilationDeclaration.js new file mode 100644 index 0000000000000..33d64b088de1e --- /dev/null +++ b/tests/baselines/reference/separateCompilationDeclaration.js @@ -0,0 +1,10 @@ +//// [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 new file mode 100644 index 0000000000000..cf05e5590a8c8 --- /dev/null +++ b/tests/baselines/reference/separateCompilationES6.js @@ -0,0 +1,5 @@ +//// [separateCompilationES6.ts] +export var x; + +//// [separateCompilationES6.js] +export var x; diff --git a/tests/baselines/reference/separateCompilationES6.types b/tests/baselines/reference/separateCompilationES6.types new file mode 100644 index 0000000000000..70381906800f1 --- /dev/null +++ b/tests/baselines/reference/separateCompilationES6.types @@ -0,0 +1,4 @@ +=== 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 new file mode 100644 index 0000000000000..db418681e8394 --- /dev/null +++ b/tests/baselines/reference/separateCompilationImportExportElision.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/separateCompilationImportExportElision.ts(2,17): error TS2307: Cannot find external module 'module'. +tests/cases/compiler/separateCompilationImportExportElision.ts(3,18): error TS2307: Cannot find external module 'module'. +tests/cases/compiler/separateCompilationImportExportElision.ts(4,21): error TS2307: Cannot find external module 'module'. +tests/cases/compiler/separateCompilationImportExportElision.ts(12,18): error TS2307: Cannot find external module 'module'. + + +==== tests/cases/compiler/separateCompilationImportExportElision.ts (4 errors) ==== + + import {c} from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find external module 'module'. + import {c2} from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find external module 'module'. + import * as ns from "module" + ~~~~~~~~ +!!! error TS2307: Cannot find external module 'module'. + + class C extends c2.C { + } + + let x = new c(); + let y = ns.value; + + export {c1} from "module"; + ~~~~~~~~ +!!! error TS2307: Cannot find external module 'module'. + export var z = x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationImportExportElision.js b/tests/baselines/reference/separateCompilationImportExportElision.js new file mode 100644 index 0000000000000..2d255798c3f41 --- /dev/null +++ b/tests/baselines/reference/separateCompilationImportExportElision.js @@ -0,0 +1,37 @@ +//// [separateCompilationImportExportElision.ts] + +import {c} from "module" +import {c2} from "module" +import * as ns from "module" + +class C extends c2.C { +} + +let x = new c(); +let y = ns.value; + +export {c1} from "module"; +export var z = x; + +//// [separateCompilationImportExportElision.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var module_1 = require("module"); +var module_2 = require("module"); +var ns = require("module"); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(module_2.c2.C); +var x = new module_1.c(); +var y = ns.value; +var module_3 = require("module"); +exports.c1 = module_3.c1; +exports.z = x; diff --git a/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt b/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt new file mode 100644 index 0000000000000..61d4f2d6d9ed8 --- /dev/null +++ b/tests/baselines/reference/separateCompilationNoEmitOnError.errors.txt @@ -0,0 +1,7 @@ +error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'. + + +!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'. +==== 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 new file mode 100644 index 0000000000000..269727584d485 --- /dev/null +++ b/tests/baselines/reference/separateCompilationNoExternalModule.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/separateCompilationNoExternalModule.ts(2,1): error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided. + + +==== tests/cases/compiler/separateCompilationNoExternalModule.ts (1 errors) ==== + + var x; + ~~~ +!!! error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationNoExternalModule.js b/tests/baselines/reference/separateCompilationNoExternalModule.js new file mode 100644 index 0000000000000..9ddc8bdef2cf8 --- /dev/null +++ b/tests/baselines/reference/separateCompilationNoExternalModule.js @@ -0,0 +1,6 @@ +//// [separateCompilationNoExternalModule.ts] + +var x; + +//// [separateCompilationNoExternalModule.js] +var x; diff --git a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.js b/tests/baselines/reference/separateCompilationNonAmbientConstEnum.js new file mode 100644 index 0000000000000..74096adca1fde --- /dev/null +++ b/tests/baselines/reference/separateCompilationNonAmbientConstEnum.js @@ -0,0 +1,14 @@ +//// [separateCompilationNonAmbientConstEnum.ts] + +const enum E { X = 100 }; +var e = E.X; +export var x; + +//// [separateCompilationNonAmbientConstEnum.js] +var E; +(function (E) { + E[E["X"] = 100] = "X"; +})(E || (E = {})); +; +var e = E.X; +export var x; diff --git a/tests/baselines/reference/separateCompilationNonAmbientConstEnum.types b/tests/baselines/reference/separateCompilationNonAmbientConstEnum.types new file mode 100644 index 0000000000000..d444cbd14933d --- /dev/null +++ b/tests/baselines/reference/separateCompilationNonAmbientConstEnum.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts === + +const enum E { X = 100 }; +>E : E +>X : E + +var e = E.X; +>e : E +>E.X : E +>E : typeof E +>X : E + +export var x; +>x : any + diff --git a/tests/baselines/reference/separateCompilationOut.errors.txt b/tests/baselines/reference/separateCompilationOut.errors.txt new file mode 100644 index 0000000000000..7c2631a71822b --- /dev/null +++ b/tests/baselines/reference/separateCompilationOut.errors.txt @@ -0,0 +1,12 @@ +error TS5046: Option 'out' cannot be specified with option 'separateCompilation'. +tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided. + + +!!! error TS5046: Option 'out' cannot be specified with option 'separateCompilation'. +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export var x; +==== tests/cases/compiler/file2.ts (1 errors) ==== + var y; + ~~~ +!!! error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided. \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationOut.js b/tests/baselines/reference/separateCompilationOut.js new file mode 100644 index 0000000000000..67dd2dcfbfabc --- /dev/null +++ b/tests/baselines/reference/separateCompilationOut.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/separateCompilationOut.ts] //// + +//// [file1.ts] + +export var x; +//// [file2.ts] +var y; + +//// [file1.js] +export var x; +//// [all.js] +var y; diff --git a/tests/baselines/reference/separateCompilationSourceMap.errors.txt b/tests/baselines/reference/separateCompilationSourceMap.errors.txt new file mode 100644 index 0000000000000..5274ef3921eaa --- /dev/null +++ b/tests/baselines/reference/separateCompilationSourceMap.errors.txt @@ -0,0 +1,7 @@ +error TS5043: Option 'sourceMap' cannot be specified with option 'separateCompilation'. + + +!!! error TS5043: Option 'sourceMap' cannot be specified with option 'separateCompilation'. +==== tests/cases/compiler/separateCompilationSourceMap.ts (0 errors) ==== + + export var x; \ No newline at end of file diff --git a/tests/baselines/reference/separateCompilationSourceMap.js b/tests/baselines/reference/separateCompilationSourceMap.js new file mode 100644 index 0000000000000..1e8f141eb47a0 --- /dev/null +++ b/tests/baselines/reference/separateCompilationSourceMap.js @@ -0,0 +1,7 @@ +//// [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 new file mode 100644 index 0000000000000..68c4e2c78dbb8 --- /dev/null +++ b/tests/baselines/reference/separateCompilationSourceMap.js.map @@ -0,0 +1,2 @@ +//// [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/separateCompilationSourceMap.sourcemap.txt b/tests/baselines/reference/separateCompilationSourceMap.sourcemap.txt new file mode 100644 index 0000000000000..74e0d73d7e03a --- /dev/null +++ b/tests/baselines/reference/separateCompilationSourceMap.sourcemap.txt @@ -0,0 +1,27 @@ +=================================================================== +JsFile: separateCompilationSourceMap.js +mapUrl: separateCompilationSourceMap.js.map +sourceRoot: +sources: separateCompilationSourceMap.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/separateCompilationSourceMap.js +sourceFile:separateCompilationSourceMap.ts +------------------------------------------------------------------- +>>>export var x; +1 > +2 >^^^^^^^^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >export var +3 > x +4 > ; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 12) Source(2, 12) + SourceIndex(0) +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 diff --git a/tests/baselines/reference/separateCompilationSpecifiedModule.js b/tests/baselines/reference/separateCompilationSpecifiedModule.js new file mode 100644 index 0000000000000..5f3c7ceb39cad --- /dev/null +++ b/tests/baselines/reference/separateCompilationSpecifiedModule.js @@ -0,0 +1,5 @@ +//// [separateCompilationSpecifiedModule.ts] +export var x; + +//// [separateCompilationSpecifiedModule.js] +exports.x; diff --git a/tests/baselines/reference/separateCompilationSpecifiedModule.types b/tests/baselines/reference/separateCompilationSpecifiedModule.types new file mode 100644 index 0000000000000..497f63faf62c6 --- /dev/null +++ b/tests/baselines/reference/separateCompilationSpecifiedModule.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/separateCompilationSpecifiedModule.ts === +export var x; +>x : any + diff --git a/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt b/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt new file mode 100644 index 0000000000000..ab0fd7ffe9d5d --- /dev/null +++ b/tests/baselines/reference/separateCompilationUnspecifiedModule.errors.txt @@ -0,0 +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 'separateCompilation' 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/baselines/reference/separateCompilationUnspecifiedModule.js b/tests/baselines/reference/separateCompilationUnspecifiedModule.js new file mode 100644 index 0000000000000..0f2e5c71a8782 --- /dev/null +++ b/tests/baselines/reference/separateCompilationUnspecifiedModule.js @@ -0,0 +1,5 @@ +//// [separateCompilationUnspecifiedModule.ts] +export var x; + +//// [separateCompilationUnspecifiedModule.js] +exports.x; diff --git a/tests/baselines/reference/separateCompilationWithDeclarationFile.js b/tests/baselines/reference/separateCompilationWithDeclarationFile.js new file mode 100644 index 0000000000000..71d7ef4192946 --- /dev/null +++ b/tests/baselines/reference/separateCompilationWithDeclarationFile.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/separateCompilationWithDeclarationFile.ts] //// + +//// [file1.d.ts] + +declare function foo(): void; + +//// [file1.ts] +export var x; + +//// [file1.js] +export var x; diff --git a/tests/baselines/reference/separateCompilationWithDeclarationFile.types b/tests/baselines/reference/separateCompilationWithDeclarationFile.types new file mode 100644 index 0000000000000..94adc5fa27e09 --- /dev/null +++ b/tests/baselines/reference/separateCompilationWithDeclarationFile.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/file1.d.ts === + +declare function foo(): void; +>foo : () => void + +=== tests/cases/compiler/file1.ts === +export var x; +>x : any + diff --git a/tests/cases/compiler/separateCompilationAmbientConstEnum.ts b/tests/cases/compiler/separateCompilationAmbientConstEnum.ts new file mode 100644 index 0000000000000..aaccfaaf02c00 --- /dev/null +++ b/tests/cases/compiler/separateCompilationAmbientConstEnum.ts @@ -0,0 +1,7 @@ +// @separateCompilation: true +// @target: es6 + +// @filename: file1.ts + +declare const enum E { X = 1} +export var y; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationDeclaration.ts b/tests/cases/compiler/separateCompilationDeclaration.ts new file mode 100644 index 0000000000000..11003a1919329 --- /dev/null +++ b/tests/cases/compiler/separateCompilationDeclaration.ts @@ -0,0 +1,6 @@ +// @separateCompilation: true +// @declaration: true +// @target: es6 + +// @filename: file1.ts +export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationES6.ts b/tests/cases/compiler/separateCompilationES6.ts new file mode 100644 index 0000000000000..a2ac8c8d94ee1 --- /dev/null +++ b/tests/cases/compiler/separateCompilationES6.ts @@ -0,0 +1,4 @@ +// @separateCompilation: 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 new file mode 100644 index 0000000000000..d7af74a1a691f --- /dev/null +++ b/tests/cases/compiler/separateCompilationImportExportElision.ts @@ -0,0 +1,17 @@ +// @separateCompilation: true +// @target: es5 +// @module: commonjs + +// @filename: file1.ts +import {c} from "module" +import {c2} from "module" +import * as ns from "module" + +class C extends c2.C { +} + +let x = new c(); +let y = ns.value; + +export {c1} from "module"; +export var z = x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationNoEmitOnError.ts b/tests/cases/compiler/separateCompilationNoEmitOnError.ts new file mode 100644 index 0000000000000..fe0f59199f661 --- /dev/null +++ b/tests/cases/compiler/separateCompilationNoEmitOnError.ts @@ -0,0 +1,6 @@ +// @separateCompilation: true +// @noEmitOnError:true +// @target: es6 + +// @filename: file1.ts +export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationNoExternalModule.ts b/tests/cases/compiler/separateCompilationNoExternalModule.ts new file mode 100644 index 0000000000000..e66ef27c00523 --- /dev/null +++ b/tests/cases/compiler/separateCompilationNoExternalModule.ts @@ -0,0 +1,5 @@ +// @separateCompilation: true +// @target: es6 + +// @filename: file1.ts +var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts b/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts new file mode 100644 index 0000000000000..5f3054238d932 --- /dev/null +++ b/tests/cases/compiler/separateCompilationNonAmbientConstEnum.ts @@ -0,0 +1,7 @@ +// @separateCompilation: true +// @target: es6 + +// @filename: file1.ts +const enum E { X = 100 }; +var e = E.X; +export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationOut.ts b/tests/cases/compiler/separateCompilationOut.ts new file mode 100644 index 0000000000000..6c0a95f8ae54c --- /dev/null +++ b/tests/cases/compiler/separateCompilationOut.ts @@ -0,0 +1,8 @@ +// @separateCompilation: true +// @out:all.js +// @target: es6 + +// @filename: file1.ts +export var x; +// @filename: file2.ts +var y; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationSourceMap.ts b/tests/cases/compiler/separateCompilationSourceMap.ts new file mode 100644 index 0000000000000..7becf7cbdaf9f --- /dev/null +++ b/tests/cases/compiler/separateCompilationSourceMap.ts @@ -0,0 +1,6 @@ +// @separateCompilation: true +// @sourceMap:sourcemap.map +// @target: es6 + +// @filename: file1.ts +export var x; \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationSpecifiedModule.ts b/tests/cases/compiler/separateCompilationSpecifiedModule.ts new file mode 100644 index 0000000000000..6ba3a0d3bf423 --- /dev/null +++ b/tests/cases/compiler/separateCompilationSpecifiedModule.ts @@ -0,0 +1,4 @@ +// @separateCompilation: 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 new file mode 100644 index 0000000000000..38a3fd82868b1 --- /dev/null +++ b/tests/cases/compiler/separateCompilationUnspecifiedModule.ts @@ -0,0 +1,3 @@ +// @separateCompilation: 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 new file mode 100644 index 0000000000000..121db1702a5ce --- /dev/null +++ b/tests/cases/compiler/separateCompilationWithDeclarationFile.ts @@ -0,0 +1,8 @@ +// @separateCompilation: true +// @target: es6 + +// @filename: file1.d.ts +declare function foo(): void; + +// @filename: file1.ts +export var x; \ No newline at end of file