diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2aee597092dd9..6bc966a11cb4d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,6 +44,7 @@ namespace ts { let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; + let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; let emitResolver = createResolver(); @@ -13379,9 +13380,9 @@ namespace ts { } } else { - if (languageVersion >= ScriptTarget.ES6 && !isInAmbientContext(node)) { + if (modulekind === ModuleKind.ES6 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -13456,11 +13457,11 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (languageVersion >= ScriptTarget.ES6) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === ModuleKind.ES6) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === ModuleKind.System) { + else if (modulekind === ModuleKind.System) { // system modules does not support export assignment grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1670251973ab1..f1d4b6e31ec37 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -76,10 +76,11 @@ namespace ts { "amd": ModuleKind.AMD, "system": ModuleKind.System, "umd": ModuleKind.UMD, + "es6": ModuleKind.ES6, }, - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: Diagnostics.KIND, - error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e6ece87b5a9bc..f9789495be1e6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -619,15 +619,15 @@ "category": "Error", "code": 1200 }, - "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": { + "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { "category": "Error", "code": 1202 }, - "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": { + "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.": { "category": "Error", "code": 1203 }, - "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.": { + "Cannot compile modules into 'es6' when targeting 'ES5' or lower.": { "category": "Error", "code": 1204 }, @@ -2101,7 +2101,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'": { + "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'": { "category": "Message", "code": 6016 }, @@ -2185,7 +2185,7 @@ "category": "Error", "code": 6045 }, - "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'.": { + "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'.": { "category": "Error", "code": 6046 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bd16b13bb0984..6a6b75af65f37 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -64,6 +64,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; + let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); @@ -188,6 +189,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** If removeComments is true, no leading-comments needed to be emitted **/ let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; + + let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number) => void> = { + [ModuleKind.ES6]: emitES6Module, + [ModuleKind.AMD]: emitAMDModule, + [ModuleKind.System]: emitSystemModule, + [ModuleKind.UMD]: emitUMDModule, + [ModuleKind.CommonJS]: emitCommonJSModule, + }; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); @@ -1493,7 +1502,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (container) { if (container.kind === SyntaxKind.SourceFile) { // Identifier references module export - if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) { + if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) { write("exports."); } } @@ -1503,7 +1512,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("."); } } - else if (languageVersion < ScriptTarget.ES6) { + else if (modulekind !== ModuleKind.ES6) { let declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (declaration.kind === SyntaxKind.ImportClause) { @@ -3056,7 +3065,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) { + else if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) { write("exports."); } } @@ -3076,7 +3085,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.parent.kind === SyntaxKind.SourceFile) { Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment); // only allow export default at a source file level - if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) { + if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === ScriptTarget.ES5) { // default value of configurable, enumerable, writable are `false`. @@ -3098,7 +3107,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitStart(node); // emit call to exporter only for top level nodes - if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) { + if (modulekind === ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(`${exportFunctionForFile}("`); @@ -3134,7 +3143,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportMemberAssignments(name: Identifier) { - if (compilerOptions.module === ModuleKind.System) { + if (modulekind === ModuleKind.System) { return; } @@ -3154,7 +3163,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void { - Debug.assert(compilerOptions.module === ModuleKind.System); + Debug.assert(modulekind === ModuleKind.System); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) { return; @@ -3491,7 +3500,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function isES6ExportedDeclaration(node: Node) { return !!(node.flags & NodeFlags.Export) && - languageVersion >= ScriptTarget.ES6 && + modulekind === ModuleKind.ES6 && node.parent.kind === SyntaxKind.SourceFile; } @@ -5257,7 +5266,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(";"); } if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { - if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) { // write the call to exporter for enum writeLine(); write(`${exportFunctionForFile}("`); @@ -5379,7 +5388,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { - if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) { writeLine(); write(`${exportFunctionForFile}("`); emitDeclarationName(node); @@ -5443,7 +5452,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitImportDeclaration(node: ImportDeclaration) { - if (languageVersion < ScriptTarget.ES6) { + if (modulekind !== ModuleKind.ES6) { return emitExternalImportDeclaration(node); } @@ -5494,7 +5503,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0; let namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -5606,15 +5615,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportDeclaration(node: ExportDeclaration) { - Debug.assert(compilerOptions.module !== ModuleKind.System); + Debug.assert(modulekind !== ModuleKind.System); - if (languageVersion < ScriptTarget.ES6) { + if (modulekind !== ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); let generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -5641,7 +5650,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // export * from "foo" writeLine(); write("__export("); - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { emitRequire(getExternalModuleName(node)); } else { @@ -5674,7 +5683,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportOrImportSpecifierList(specifiers: ImportOrExportSpecifier[], shouldEmit: (node: Node) => boolean) { - Debug.assert(languageVersion >= ScriptTarget.ES6); + Debug.assert(modulekind === ModuleKind.ES6); let needsComma = false; for (let specifier of specifiers) { @@ -5694,7 +5703,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitExportAssignment(node: ExportAssignment) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= ScriptTarget.ES6) { + if (modulekind === ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); @@ -5709,7 +5718,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { writeLine(); emitStart(node); - if (compilerOptions.module === ModuleKind.System) { + if (modulekind === ModuleKind.System) { write(`${exportFunctionForFile}("default",`); emit(node.expression); write(")"); @@ -6155,7 +6164,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === ModuleKind.System && isExternalModule(currentSourceFile); + return modulekind === ModuleKind.System && isExternalModule(currentSourceFile); } function emitSystemModuleBody(node: SourceFile, dependencyGroups: DependencyGroup[], startIndex: number): void { @@ -6713,21 +6722,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= ScriptTarget.ES6) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.AMD) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.System) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.UMD) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; + emitModule(node, startIndex); } else { externalImports = undefined; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3da3c354fb236..0dbaa3b39b251 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1022,9 +1022,9 @@ namespace ts { programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= ScriptTarget.ES6) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d2757bb7937ca..2cb429a993e80 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2076,6 +2076,7 @@ namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } export const enum JsxEmit { diff --git a/tests/baselines/reference/constDeclarations-access5.errors.txt b/tests/baselines/reference/constDeclarations-access5.errors.txt index d58abfe6bd4a3..23200e50ee42b 100644 --- a/tests/baselines/reference/constDeclarations-access5.errors.txt +++ b/tests/baselines/reference/constDeclarations-access5.errors.txt @@ -1,5 +1,3 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant. @@ -20,12 +18,9 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant. -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ==== +==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ==== /// import m = require('constDeclarations_access_1'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. // Errors m.x = 1; ~~~ diff --git a/tests/baselines/reference/constDeclarations-access5.js b/tests/baselines/reference/constDeclarations-access5.js index 7735e37d2b0c3..71b8c99ae58f0 100644 --- a/tests/baselines/reference/constDeclarations-access5.js +++ b/tests/baselines/reference/constDeclarations-access5.js @@ -49,35 +49,39 @@ m.x.toString(); //// [constDeclarations_access_1.js] -export const x = 0; +define(["require", "exports"], function (require, exports) { + exports.x = 0; +}); //// [constDeclarations_access_2.js] -// Errors -m.x = 1; -m.x += 2; -m.x -= 3; -m.x *= 4; -m.x /= 5; -m.x %= 6; -m.x <<= 7; -m.x >>= 8; -m.x >>>= 9; -m.x &= 10; -m.x |= 11; -m.x ^= 12; -m; -m.x++; -m.x--; -++m.x; ---m.x; -++((m.x)); -m["x"] = 0; -// OK -var a = m.x + 1; -function f(v) { } -f(m.x); -if (m.x) { } -m.x; -(m.x); --m.x; -+m.x; -m.x.toString(); +define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) { + // Errors + m.x = 1; + m.x += 2; + m.x -= 3; + m.x *= 4; + m.x /= 5; + m.x %= 6; + m.x <<= 7; + m.x >>= 8; + m.x >>>= 9; + m.x &= 10; + m.x |= 11; + m.x ^= 12; + m; + m.x++; + m.x--; + ++m.x; + --m.x; + ++((m.x)); + m["x"] = 0; + // OK + var a = m.x + 1; + function f(v) { } + f(m.x); + if (m.x) { } + m.x; + (m.x); + -m.x; + +m.x; + m.x.toString(); +}); diff --git a/tests/baselines/reference/es5andes6module.errors.txt b/tests/baselines/reference/es5andes6module.errors.txt new file mode 100644 index 0000000000000..d5a672b948628 --- /dev/null +++ b/tests/baselines/reference/es5andes6module.errors.txt @@ -0,0 +1,19 @@ +error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower. + + +!!! error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower. +==== tests/cases/compiler/es5andes6module.ts (0 errors) ==== + + export default class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/es5andes6module.js b/tests/baselines/reference/es5andes6module.js new file mode 100644 index 0000000000000..0d489357852cb --- /dev/null +++ b/tests/baselines/reference/es5andes6module.js @@ -0,0 +1,26 @@ +//// [es5andes6module.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5andes6module.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +exports.default = A; diff --git a/tests/baselines/reference/es6-amd.errors.txt b/tests/baselines/reference/es6-amd.errors.txt deleted file mode 100644 index b4a6442458b78..0000000000000 --- a/tests/baselines/reference/es6-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.symbols b/tests/baselines/reference/es6-amd.symbols new file mode 100644 index 0000000000000..ad5cf38e7cd09 --- /dev/null +++ b/tests/baselines/reference/es6-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-amd.ts === + +class A +>A : Symbol(A, Decl(es6-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-amd.types b/tests/baselines/reference/es6-amd.types new file mode 100644 index 0000000000000..7a6fb6e32f559 --- /dev/null +++ b/tests/baselines/reference/es6-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-declaration-amd.errors.txt b/tests/baselines/reference/es6-declaration-amd.errors.txt deleted file mode 100644 index fe5a254dd54a4..0000000000000 --- a/tests/baselines/reference/es6-declaration-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.symbols b/tests/baselines/reference/es6-declaration-amd.symbols new file mode 100644 index 0000000000000..f1a728396cc58 --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-declaration-amd.ts === + +class A +>A : Symbol(A, Decl(es6-declaration-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-declaration-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-declaration-amd.types b/tests/baselines/reference/es6-declaration-amd.types new file mode 100644 index 0000000000000..a46d22c82c58d --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-declaration-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-sourcemap-amd.errors.txt b/tests/baselines/reference/es6-sourcemap-amd.errors.txt deleted file mode 100644 index 8ffa16aaa2397..0000000000000 --- a/tests/baselines/reference/es6-sourcemap-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.symbols b/tests/baselines/reference/es6-sourcemap-amd.symbols new file mode 100644 index 0000000000000..13be6367ba0d3 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-sourcemap-amd.ts === + +class A +>A : Symbol(A, Decl(es6-sourcemap-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-sourcemap-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-sourcemap-amd.types b/tests/baselines/reference/es6-sourcemap-amd.types new file mode 100644 index 0000000000000..580a688afab44 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-sourcemap-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-umd.errors.txt b/tests/baselines/reference/es6-umd.errors.txt deleted file mode 100644 index 72a58585073bc..0000000000000 --- a/tests/baselines/reference/es6-umd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-umd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.symbols b/tests/baselines/reference/es6-umd.symbols new file mode 100644 index 0000000000000..f7c57215ea6d3 --- /dev/null +++ b/tests/baselines/reference/es6-umd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-umd.ts === + +class A +>A : Symbol(A, Decl(es6-umd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-umd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-umd.types b/tests/baselines/reference/es6-umd.types new file mode 100644 index 0000000000000..f43c491e003a5 --- /dev/null +++ b/tests/baselines/reference/es6-umd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-umd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-umd2.errors.txt b/tests/baselines/reference/es6-umd2.errors.txt deleted file mode 100644 index 00becfb105fa1..0000000000000 --- a/tests/baselines/reference/es6-umd2.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-umd2.ts (0 errors) ==== - - export class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js index 416932d89bc2a..04c17d49951fb 100644 --- a/tests/baselines/reference/es6-umd2.js +++ b/tests/baselines/reference/es6-umd2.js @@ -14,10 +14,20 @@ export class A } //// [es6-umd2.js] -export class A { - constructor() { +(function (deps, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; } - B() { - return 42; + else if (typeof define === 'function' && define.amd) { + define(deps, factory); } -} +})(["require", "exports"], function (require, exports) { + class A { + constructor() { + } + B() { + return 42; + } + } + exports.A = A; +}); diff --git a/tests/baselines/reference/es6-umd2.symbols b/tests/baselines/reference/es6-umd2.symbols new file mode 100644 index 0000000000000..88acf1272798e --- /dev/null +++ b/tests/baselines/reference/es6-umd2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-umd2.ts === + +export class A +>A : Symbol(A, Decl(es6-umd2.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-umd2.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-umd2.types b/tests/baselines/reference/es6-umd2.types new file mode 100644 index 0000000000000..eb66523c6ecec --- /dev/null +++ b/tests/baselines/reference/es6-umd2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-umd2.ts === + +export class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt index 1db7d04e05e9f..970d2e184dc51 100644 --- a/tests/baselines/reference/es6ExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ==== @@ -6,4 +6,4 @@ tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignmen var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment2.errors.txt b/tests/baselines/reference/es6ExportAssignment2.errors.txt index d5e1dfebd9df7..248491f98c3ac 100644 --- a/tests/baselines/reference/es6ExportAssignment2.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/a.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used w var a = 10; export = a; // Error: export = not allowed in ES6 ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/b.ts (0 errors) ==== import * as a from "a"; diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index 174c72341f6c9..e8db09456d3e1 100644 --- a/tests/baselines/reference/es6ExportEquals.errors.txt +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -8,7 +8,7 @@ tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment export = f; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt deleted file mode 100644 index b0b7465477ba7..0000000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ==== - - export var a = 10; - export var x = a; - export var m = a; - export default {}; - -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (0 errors) ==== - import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = a; - import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = b; - import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = x; - var x1: number = y; - import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = z; - import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = m; - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 554fecf9116ca..d6be494a8d1ad 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -23,22 +23,22 @@ var x1: number = m; //// [es6ImportDefaultBindingFollowedWithNamedImport_0.js] -export var a = 10; -export var x = a; -export var m = a; -export default {}; +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.default = {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] -import { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = a; -import { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = b; -import { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = x; -var x1 = y; -import { x as z } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = z; -import { m } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = m; +var es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_1.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_2.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.x; +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_4.x; +var es6ImportDefaultBindingFollowedWithNamedImport_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_5.m; //// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols new file mode 100644 index 0000000000000..5da138f6c6242 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols @@ -0,0 +1,67 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export var x = a; +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 2, 10)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export var m = a; +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 3, 10)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export default {}; + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts === +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding1 : Symbol(defaultBinding1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 0, 6)) + +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 6)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25)) + +var x1: number = a; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25)) + +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding3 : Symbol(defaultBinding3, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 6)) +>a : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) +>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) + +var x1: number = b; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) + +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding4 : Symbol(defaultBinding4, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 6)) +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25)) +>a : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) +>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) + +var x1: number = x; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25)) + +var x1: number = y; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) + +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding5 : Symbol(defaultBinding5, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 6)) +>x : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) +>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) + +var x1: number = z; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) + +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding6 : Symbol(defaultBinding6, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 6)) +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25)) + +var x1: number = m; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25)) + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types new file mode 100644 index 0000000000000..fe0137403a982 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export default {}; +>{} : {} + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts === +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding1 : {} + +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding2 : {} +>a : number + +var x1: number = a; +>x1 : number +>a : number + +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding3 : {} +>a : number +>b : number + +var x1: number = b; +>x1 : number +>b : number + +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding4 : {} +>x : number +>a : number +>y : number + +var x1: number = x; +>x1 : number +>x : number + +var x1: number = y; +>x1 : number +>y : number + +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding5 : {} +>x : number +>z : number + +var x1: number = z; +>x1 : number +>z : number + +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding6 : {} +>m : number + +var x1: number = m; +>x1 : number +>m : number + diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt index d3351ee97b22c..7de5d7f0e3d0f 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. -tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/client.ts (1 errors) ==== import a = require("server"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ==== tests/cases/compiler/server.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt deleted file mode 100644 index 67616662ca832..0000000000000 --- a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ==== - - export var a = 10; - -==== tests/cases/compiler/es6ImportNameSpaceImport_1.ts (0 errors) ==== - import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; - var x = nameSpaceBinding.a; - import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index 7498b8ee9e867..32bdd78b32995 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -11,9 +11,9 @@ import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this //// [es6ImportNameSpaceImport_0.js] -export var a = 10; +exports.a = 10; //// [es6ImportNameSpaceImport_1.js] -import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; +var nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.symbols b/tests/baselines/reference/es6ImportNameSpaceImport.symbols new file mode 100644 index 0000000000000..add2b792d4916 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImport.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) + +=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts === +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; +>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6)) + +var x = nameSpaceBinding.a; +>x : Symbol(x, Decl(es6ImportNameSpaceImport_1.ts, 1, 3)) +>nameSpaceBinding.a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) +>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6)) +>a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) + +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this +>nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(es6ImportNameSpaceImport_1.ts, 2, 6)) + diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.types b/tests/baselines/reference/es6ImportNameSpaceImport.types new file mode 100644 index 0000000000000..56ee0c4d87a99 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImport.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts === +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; +>nameSpaceBinding : typeof nameSpaceBinding + +var x = nameSpaceBinding.a; +>x : number +>nameSpaceBinding.a : number +>nameSpaceBinding : typeof nameSpaceBinding +>a : number + +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this +>nameSpaceBinding2 : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNamedImport.errors.txt b/tests/baselines/reference/es6ImportNamedImport.errors.txt deleted file mode 100644 index efcda1f536874..0000000000000 --- a/tests/baselines/reference/es6ImportNamedImport.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ==== - - export var a = 10; - export var x = a; - export var m = a; - export var a1 = 10; - export var x1 = 10; - export var z1 = 10; - export var z2 = 10; - export var aaaa = 10; - -==== tests/cases/compiler/es6ImportNamedImport_1.ts (0 errors) ==== - import { } from "./es6ImportNamedImport_0"; - import { a } from "./es6ImportNamedImport_0"; - var xxxx = a; - import { a as b } from "./es6ImportNamedImport_0"; - var xxxx = b; - import { x, a as y } from "./es6ImportNamedImport_0"; - var xxxx = x; - var xxxx = y; - import { x as z, } from "./es6ImportNamedImport_0"; - var xxxx = z; - import { m, } from "./es6ImportNamedImport_0"; - var xxxx = m; - import { a1, x1 } from "./es6ImportNamedImport_0"; - var xxxx = a1; - var xxxx = x1; - import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; - var xxxx = a11; - var xxxx = x11; - import { z1 } from "./es6ImportNamedImport_0"; - var z111 = z1; - import { z2 as z3 } from "./es6ImportNamedImport_0"; - var z2 = z3; // z2 shouldn't give redeclare error - - // These are elided - import { aaaa } from "./es6ImportNamedImport_0"; - // These are elided - import { aaaa as bbbb } from "./es6ImportNamedImport_0"; - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index 6edb6ccb7cd8c..3ed7a6adeb03d 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -42,36 +42,36 @@ import { aaaa as bbbb } from "./es6ImportNamedImport_0"; //// [es6ImportNamedImport_0.js] -export var a = 10; -export var x = a; -export var m = a; -export var a1 = 10; -export var x1 = 10; -export var z1 = 10; -export var z2 = 10; -export var aaaa = 10; +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.a1 = 10; +exports.x1 = 10; +exports.z1 = 10; +exports.z2 = 10; +exports.aaaa = 10; //// [es6ImportNamedImport_1.js] -import { a } from "./es6ImportNamedImport_0"; -var xxxx = a; -import { a as b } from "./es6ImportNamedImport_0"; -var xxxx = b; -import { x, a as y } from "./es6ImportNamedImport_0"; -var xxxx = x; -var xxxx = y; -import { x as z } from "./es6ImportNamedImport_0"; -var xxxx = z; -import { m } from "./es6ImportNamedImport_0"; -var xxxx = m; -import { a1, x1 } from "./es6ImportNamedImport_0"; -var xxxx = a1; -var xxxx = x1; -import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; -var xxxx = a11; -var xxxx = x11; -import { z1 } from "./es6ImportNamedImport_0"; -var z111 = z1; -import { z2 as z3 } from "./es6ImportNamedImport_0"; -var z2 = z3; // z2 shouldn't give redeclare error +var es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_1.a; +var es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_2.a; +var es6ImportNamedImport_0_3 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_3.x; +var xxxx = es6ImportNamedImport_0_3.a; +var es6ImportNamedImport_0_4 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_4.x; +var es6ImportNamedImport_0_5 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_5.m; +var es6ImportNamedImport_0_6 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_6.a1; +var xxxx = es6ImportNamedImport_0_6.x1; +var es6ImportNamedImport_0_7 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_7.a1; +var xxxx = es6ImportNamedImport_0_7.x1; +var es6ImportNamedImport_0_8 = require("./es6ImportNamedImport_0"); +var z111 = es6ImportNamedImport_0_8.z1; +var es6ImportNamedImport_0_9 = require("./es6ImportNamedImport_0"); +var z2 = es6ImportNamedImport_0_9.z2; // z2 shouldn't give redeclare error //// [es6ImportNamedImport_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImport.symbols b/tests/baselines/reference/es6ImportNamedImport.symbols new file mode 100644 index 0000000000000..0d30db6113fe4 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImport.symbols @@ -0,0 +1,123 @@ +=== tests/cases/compiler/es6ImportNamedImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var x = a; +>x : Symbol(x, Decl(es6ImportNamedImport_0.ts, 2, 10)) +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var m = a; +>m : Symbol(m, Decl(es6ImportNamedImport_0.ts, 3, 10)) +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var a1 = 10; +>a1 : Symbol(a1, Decl(es6ImportNamedImport_0.ts, 4, 10)) + +export var x1 = 10; +>x1 : Symbol(x1, Decl(es6ImportNamedImport_0.ts, 5, 10)) + +export var z1 = 10; +>z1 : Symbol(z1, Decl(es6ImportNamedImport_0.ts, 6, 10)) + +export var z2 = 10; +>z2 : Symbol(z2, Decl(es6ImportNamedImport_0.ts, 7, 10)) + +export var aaaa = 10; +>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_0.ts, 8, 10)) + +=== tests/cases/compiler/es6ImportNamedImport_1.ts === +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; +>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8)) + +var xxxx = a; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8)) + +import { a as b } from "./es6ImportNamedImport_0"; +>a : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) +>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) + +var xxxx = b; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) + +import { x, a as y } from "./es6ImportNamedImport_0"; +>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8)) +>a : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) +>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) + +var xxxx = x; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8)) + +var xxxx = y; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) + +import { x as z, } from "./es6ImportNamedImport_0"; +>x : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) +>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) + +var xxxx = z; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) + +import { m, } from "./es6ImportNamedImport_0"; +>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8)) + +var xxxx = m; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8)) + +import { a1, x1 } from "./es6ImportNamedImport_0"; +>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8)) +>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12)) + +var xxxx = a1; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8)) + +var xxxx = x1; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12)) + +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; +>a1 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) +>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) +>x1 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) +>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) + +var xxxx = a11; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) + +var xxxx = x11; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) + +import { z1 } from "./es6ImportNamedImport_0"; +>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8)) + +var z111 = z1; +>z111 : Symbol(z111, Decl(es6ImportNamedImport_1.ts, 19, 3)) +>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8)) + +import { z2 as z3 } from "./es6ImportNamedImport_0"; +>z2 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) +>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : Symbol(z2, Decl(es6ImportNamedImport_1.ts, 21, 3)) +>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) + +// These are elided +import { aaaa } from "./es6ImportNamedImport_0"; +>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_1.ts, 24, 8)) + +// These are elided +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; +>aaaa : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8)) +>bbbb : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8)) + diff --git a/tests/baselines/reference/es6ImportNamedImport.types b/tests/baselines/reference/es6ImportNamedImport.types new file mode 100644 index 0000000000000..bd7c43d70319b --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImport.types @@ -0,0 +1,129 @@ +=== tests/cases/compiler/es6ImportNamedImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export var a1 = 10; +>a1 : number +>10 : number + +export var x1 = 10; +>x1 : number +>10 : number + +export var z1 = 10; +>z1 : number +>10 : number + +export var z2 = 10; +>z2 : number +>10 : number + +export var aaaa = 10; +>aaaa : number +>10 : number + +=== tests/cases/compiler/es6ImportNamedImport_1.ts === +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; +>a : number + +var xxxx = a; +>xxxx : number +>a : number + +import { a as b } from "./es6ImportNamedImport_0"; +>a : number +>b : number + +var xxxx = b; +>xxxx : number +>b : number + +import { x, a as y } from "./es6ImportNamedImport_0"; +>x : number +>a : number +>y : number + +var xxxx = x; +>xxxx : number +>x : number + +var xxxx = y; +>xxxx : number +>y : number + +import { x as z, } from "./es6ImportNamedImport_0"; +>x : number +>z : number + +var xxxx = z; +>xxxx : number +>z : number + +import { m, } from "./es6ImportNamedImport_0"; +>m : number + +var xxxx = m; +>xxxx : number +>m : number + +import { a1, x1 } from "./es6ImportNamedImport_0"; +>a1 : number +>x1 : number + +var xxxx = a1; +>xxxx : number +>a1 : number + +var xxxx = x1; +>xxxx : number +>x1 : number + +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; +>a1 : number +>a11 : number +>x1 : number +>x11 : number + +var xxxx = a11; +>xxxx : number +>a11 : number + +var xxxx = x11; +>xxxx : number +>x11 : number + +import { z1 } from "./es6ImportNamedImport_0"; +>z1 : number + +var z111 = z1; +>z111 : number +>z1 : number + +import { z2 as z3 } from "./es6ImportNamedImport_0"; +>z2 : number +>z3 : number + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : number +>z3 : number + +// These are elided +import { aaaa } from "./es6ImportNamedImport_0"; +>aaaa : number + +// These are elided +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; +>aaaa : number +>bbbb : number + diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt deleted file mode 100644 index fec4d18215802..0000000000000 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ==== - - export var a = 10; - -==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts (1 errors) ==== - import { a } from "./es6ImportNamedImportInExportAssignment_0"; - export = a; - ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js index 44ac0d188b327..5bdbd89df0786 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -9,9 +9,10 @@ import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; //// [es6ImportNamedImportInExportAssignment_0.js] -export var a = 10; +exports.a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] -import { a } from "./es6ImportNamedImportInExportAssignment_0"; +var es6ImportNamedImportInExportAssignment_0_1 = require("./es6ImportNamedImportInExportAssignment_0"); +module.exports = es6ImportNamedImportInExportAssignment_0_1.a; //// [es6ImportNamedImportInExportAssignment_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols new file mode 100644 index 0000000000000..03ca0740f08a9 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_0.ts, 1, 10)) + +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === +import { a } from "./es6ImportNamedImportInExportAssignment_0"; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8)) + +export = a; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8)) + diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types new file mode 100644 index 0000000000000..09023b6dd8097 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts === + +export var a = 10; +>a : number +>10 : number + +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === +import { a } from "./es6ImportNamedImportInExportAssignment_0"; +>a : number + +export = a; +>a : number + diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt deleted file mode 100644 index 9592a9f899e64..0000000000000 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ==== - export class A - { - constructor () - { - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js index 8757bd1c88f52..dec8de1e36ee1 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js @@ -12,10 +12,13 @@ export class A } //// [es6ModuleWithModuleGenTargetAmd.js] -export class A { - constructor() { +define(["require", "exports"], function (require, exports) { + class A { + constructor() { + } + B() { + return 42; + } } - B() { - return 42; - } -} + exports.A = A; +}); diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols new file mode 100644 index 0000000000000..24367cc28ad39 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts === +export class A +>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetAmd.ts, 0, 0)) +{ + constructor () + { + } + + public B() +>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetAmd.ts, 4, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types new file mode 100644 index 0000000000000..067ceb005e8e2 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts === +export class A +>A : A +{ + constructor () + { + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt deleted file mode 100644 index b740104009982..0000000000000 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ==== - export class A - { - constructor () - { - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js index 2df98e20826aa..36e66cb572135 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js @@ -12,10 +12,11 @@ export class A } //// [es6ModuleWithModuleGenTargetCommonjs.js] -export class A { +class A { constructor() { } B() { return 42; } } +exports.A = A; diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols new file mode 100644 index 0000000000000..4a84c00c48ffe --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts === +export class A +>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 0, 0)) +{ + constructor () + { + } + + public B() +>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 4, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types new file mode 100644 index 0000000000000..58f0f89f955d8 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts === +export class A +>A : A +{ + constructor () + { + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6modulekind.js b/tests/baselines/reference/es6modulekind.js new file mode 100644 index 0000000000000..96b315389d10e --- /dev/null +++ b/tests/baselines/reference/es6modulekind.js @@ -0,0 +1,23 @@ +//// [es6modulekind.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6modulekind.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/es6modulekind.symbols b/tests/baselines/reference/es6modulekind.symbols new file mode 100644 index 0000000000000..0b5eeb2a6fb07 --- /dev/null +++ b/tests/baselines/reference/es6modulekind.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6modulekind.ts === + +export default class A +>A : Symbol(A, Decl(es6modulekind.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6modulekind.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6modulekind.types b/tests/baselines/reference/es6modulekind.types new file mode 100644 index 0000000000000..d7fde0c7d4426 --- /dev/null +++ b/tests/baselines/reference/es6modulekind.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6modulekind.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/systemModule1.errors.txt b/tests/baselines/reference/systemModule1.errors.txt deleted file mode 100644 index 18b64607455e3..0000000000000 --- a/tests/baselines/reference/systemModule1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/systemModule1.ts (0 errors) ==== - - export var x = 1; \ No newline at end of file diff --git a/tests/baselines/reference/systemModule1.js b/tests/baselines/reference/systemModule1.js index 9731106471c84..573a7ae04c883 100644 --- a/tests/baselines/reference/systemModule1.js +++ b/tests/baselines/reference/systemModule1.js @@ -3,4 +3,12 @@ export var x = 1; //// [systemModule1.js] -export var x = 1; +System.register([], function(exports_1) { + var x; + return { + setters:[], + execute: function() { + x = 1; + } + } +}); diff --git a/tests/baselines/reference/systemModule1.symbols b/tests/baselines/reference/systemModule1.symbols new file mode 100644 index 0000000000000..d6293c21fd9a9 --- /dev/null +++ b/tests/baselines/reference/systemModule1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/systemModule1.ts === + +export var x = 1; +>x : Symbol(x, Decl(systemModule1.ts, 1, 10)) + diff --git a/tests/baselines/reference/systemModule1.types b/tests/baselines/reference/systemModule1.types new file mode 100644 index 0000000000000..2adf73d116f88 --- /dev/null +++ b/tests/baselines/reference/systemModule1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/systemModule1.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/cases/compiler/es5andes6module.ts b/tests/cases/compiler/es5andes6module.ts new file mode 100644 index 0000000000000..0fbff3c23d25d --- /dev/null +++ b/tests/cases/compiler/es5andes6module.ts @@ -0,0 +1,17 @@ +// @target: ES5 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} diff --git a/tests/cases/compiler/es6modulekind.ts b/tests/cases/compiler/es6modulekind.ts new file mode 100644 index 0000000000000..0722e1690a3c8 --- /dev/null +++ b/tests/cases/compiler/es6modulekind.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file