diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 76e2fe0e351f7..073e352f22336 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2168,10 +2168,26 @@ namespace ts { function nextTokenCanFollowDefaultKeyword(): boolean { nextToken(); - return token() === SyntaxKind.ClassKeyword || token() === SyntaxKind.FunctionKeyword || - token() === SyntaxKind.InterfaceKeyword || - (token() === SyntaxKind.AbstractKeyword && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === SyntaxKind.AsyncKeyword && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + switch (token()) { + case SyntaxKind.ClassKeyword: + case SyntaxKind.InterfaceKeyword: + case SyntaxKind.FunctionKeyword: + case SyntaxKind.NamespaceKeyword: + case SyntaxKind.ModuleKeyword: + case SyntaxKind.EnumKeyword: + case SyntaxKind.ConstKeyword: + return true; + case SyntaxKind.DeclareKeyword: + return lookAhead(nextTokenCanFollowExportDefaultDeclareKeyword); + case SyntaxKind.TypeKeyword: + return lookAhead(nextTokenIsIdentifierOnSameLine); + case SyntaxKind.AbstractKeyword: + return lookAhead(nextTokenIsClassKeywordOnSameLine); + case SyntaxKind.AsyncKeyword: + return lookAhead(nextTokenIsFunctionKeywordOnSameLine); + default: + return false; + } } // True if positioned at the start of a list element @@ -6339,6 +6355,18 @@ namespace ts { return token() === SyntaxKind.ClassKeyword && !scanner.hasPrecedingLineBreak(); } + function nextTokenCanFollowExportDefaultDeclareKeyword() { + nextToken(); + switch (token()) { + case SyntaxKind.NamespaceKeyword: + case SyntaxKind.ModuleKeyword: + case SyntaxKind.ClassKeyword: + return !scanner.hasPrecedingLineBreak(); + default: + return false; + } + } + function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); return token() === SyntaxKind.FunctionKeyword && !scanner.hasPrecedingLineBreak(); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 52242ccba4582..0e7b9c7a4acfb 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1478,91 +1478,7 @@ namespace ts { * @param node The enum declaration node. */ function visitEnumDeclaration(node: EnumDeclaration): VisitResult { - if (!shouldEmitEnumDeclaration(node)) { - return factory.createNotEmittedStatement(node); - } - - const statements: Statement[] = []; - - // We request to be advised when the printer is about to print this node. This allows - // us to set up the correct state for later substitutions. - let emitFlags = EmitFlags.AdviseOnEmitNode; - - // If needed, we should emit a variable declaration for the enum. If we emit - // a leading variable declaration, we should not emit leading comments for the - // enum body. - const varAdded = addVarForEnumOrModuleDeclaration(statements, node); - if (varAdded) { - // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= EmitFlags.NoLeadingComments; - } - } - - // `parameterName` is the declaration name used inside of the enum. - const parameterName = getNamespaceParameterName(node); - - // `containerName` is the expression used inside of the enum for assignments. - const containerName = getNamespaceContainerName(node); - - // `exportName` is the expression used within this node's container for any exported references. - const exportName = hasSyntacticModifier(node, ModifierFlags.Export) - ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) - : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); - - // x || (x = {}) - // exports.x || (exports.x = {}) - let moduleArg = - factory.createLogicalOr( - exportName, - factory.createAssignment( - exportName, - factory.createObjectLiteralExpression() - ) - ); - - if (hasNamespaceQualifiedExportName(node)) { - // `localName` is the expression used within this node's containing scope for any local references. - const localName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); - - // x = (exports.x || (exports.x = {})) - moduleArg = factory.createAssignment(localName, moduleArg); - } - - // (function (x) { - // x[x["y"] = 0] = "y"; - // ... - // })(x || (x = {})); - const enumStatement = factory.createExpressionStatement( - factory.createCallExpression( - factory.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], - /*type*/ undefined, - transformEnumBody(node, containerName) - ), - /*typeArguments*/ undefined, - [moduleArg] - ) - ); - - setOriginalNode(enumStatement, node); - if (varAdded) { - // If a variable was added, synthetic comments are emitted on it, not on the moduleStatement. - setSyntheticLeadingComments(enumStatement, undefined); - setSyntheticTrailingComments(enumStatement, undefined); - } - setTextRange(enumStatement, node); - addEmitFlags(enumStatement, emitFlags); - statements.push(enumStatement); - - // Add a DeclarationMarker for the enum to preserve trailing comments and mark - // the end of the declaration. - statements.push(factory.createEndOfDeclarationMarker(node)); - return statements; + return shouldEmitEnumDeclaration(node) ? createIIFEModule(node) : factory.createNotEmittedStatement(node); } /** @@ -1706,55 +1622,52 @@ namespace ts { return node.name.escapedText; } - /** - * Adds a leading VariableStatement for a enum or module declaration. - */ - function addVarForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration) { - // Emit a variable statement for the module. We emit top-level enums as a `var` - // declaration to avoid static errors in global scripts scripts due to redeclaration. - // enums in any other scope are emitted as a `let` declaration. - const statement = factory.createVariableStatement( - visitNodes(node.modifiers, modifierVisitor, isModifier), - factory.createVariableDeclarationList([ - factory.createVariableDeclaration( - factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) - ) - ], currentLexicalScope.kind === SyntaxKind.SourceFile ? NodeFlags.None : NodeFlags.Let) + function addExportVariableForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration, name: Identifier, modifierFlags: ModifierFlags): boolean { + const nodeFlags = currentLexicalScope.kind === SyntaxKind.SourceFile ? NodeFlags.None : NodeFlags.Let; + const isDefaultExport = modifierFlags & ModifierFlags.Export && modifierFlags & ModifierFlags.Default; + const variableDeclaration = isDefaultExport + ? factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createObjectLiteralExpression()) + : factory.createVariableDeclaration(name); + const variableStatement = factory.createVariableStatement( + isDefaultExport ? undefined : visitNodes(node.modifiers, modifierVisitor, isModifier), + factory.createVariableDeclarationList([variableDeclaration], nodeFlags) ); - setOriginalNode(statement, node); - + setOriginalNode(variableStatement, node); recordEmittedDeclarationInScope(node); - if (isFirstEmittedDeclarationInScope(node)) { - // Adjust the source map emit to match the old emitter. - if (node.kind === SyntaxKind.EnumDeclaration) { - setSourceMapRange(statement.declarationList, node); - } - else { - setSourceMapRange(statement, node); - } + if (isFirstEmittedDeclarationInScope(node)) { // Trailing comments for module declaration should be emitted after the function closure // instead of the variable statement: // // /** Module comment*/ // module m1 { - // function foo4Export() { - // } + // function foo4Export() {} // } // trailing comment module // // Should emit: - // // /** Module comment*/ // var m1; // (function (m1) { - // function foo4Export() { - // } + // function foo4Export() {} // })(m1 || (m1 = {})); // trailing comment module - // - setCommentRange(statement, node); - addEmitFlags(statement, EmitFlags.NoTrailingComments | EmitFlags.HasEndOfDeclarationMarker); - statements.push(statement); + setSourceMapRange(isEnumDeclaration(node) ? variableStatement.declarationList : variableStatement, node); + setCommentRange(variableStatement, node); + addEmitFlags(variableStatement, EmitFlags.NoTrailingComments | EmitFlags.HasEndOfDeclarationMarker); + statements.push(variableStatement); + + if (isDefaultExport) { + // export module m { + // export const foo = 1; + // } + // Should emit: + // var m = {}; + // export default m; + // (function (m) { + // m.foo = 1; + // })(m); + statements.push(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportEquals*/ false, name)); + } return true; } else { @@ -1762,77 +1675,53 @@ namespace ts { // declaration we do not emit a leading variable declaration. To preserve the // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. - const mergeMarker = factory.createMergeDeclarationMarker(statement); + const mergeMarker = factory.createMergeDeclarationMarker(variableStatement); setEmitFlags(mergeMarker, EmitFlags.NoComments | EmitFlags.HasEndOfDeclarationMarker); statements.push(mergeMarker); return false; } } - /** - * Visits a module declaration node. - * - * This function will be called any time a TypeScript namespace (ModuleDeclaration) is encountered. - * - * @param node The module declaration node. - */ - function visitModuleDeclaration(node: ModuleDeclaration): VisitResult { - if (!shouldEmitModuleDeclaration(node)) { - return factory.createNotEmittedStatement(node); + function getIIFEModuleArgument(node: ModuleDeclaration | EnumDeclaration, name: Identifier, modifierFlags: ModifierFlags) { + if (modifierFlags & ModifierFlags.Export && modifierFlags & ModifierFlags.Default) { + return name; } - Debug.assertNode(node.name, isIdentifier, "A TypeScript namespace should have an Identifier name."); - enableSubstitutionForNamespaceExports(); - - const statements: Statement[] = []; - - // We request to be advised when the printer is about to print this node. This allows - // us to set up the correct state for later substitutions. - let emitFlags = EmitFlags.AdviseOnEmitNode; - - // If needed, we should emit a variable declaration for the module. If we emit - // a leading variable declaration, we should not emit leading comments for the - // module body. - const varAdded = addVarForEnumOrModuleDeclaration(statements, node); - if (varAdded) { - // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= EmitFlags.NoLeadingComments; - } - } - - // `parameterName` is the declaration name used inside of the namespace. - const parameterName = getNamespaceParameterName(node); - - // `containerName` is the expression used inside of the namespace for exports. - const containerName = getNamespaceContainerName(node); - // `exportName` is the expression used within this node's container for any exported references. - const exportName = hasSyntacticModifier(node, ModifierFlags.Export) + const exportName = modifierFlags & ModifierFlags.Export ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) // exports.x || (exports.x = {}) - let moduleArg = - factory.createLogicalOr( - exportName, - factory.createAssignment( - exportName, - factory.createObjectLiteralExpression() - ) - ); + const arg = factory.createLogicalOr(exportName, + factory.createAssignment(exportName, factory.createObjectLiteralExpression())); - if (hasNamespaceQualifiedExportName(node)) { - // `localName` is the expression used within this node's containing scope for any local references. - const localName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + return hasNamespaceQualifiedExportName(node) + ? factory.createAssignment(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true), arg) + : arg; + } - // x = (exports.x || (exports.x = {})) - moduleArg = factory.createAssignment(localName, moduleArg); - } + /** + * Adds a leading VariableStatement for a enum or module declaration. + */ + function createIIFEModule(node: ModuleDeclaration | EnumDeclaration) { + const statements: Statement[] = []; + const modifierFlags = getSyntacticModifierFlags(node); + const localName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + const exportVariableAdded = addExportVariableForEnumOrModuleDeclaration(statements, node, localName, modifierFlags); + const emitFlags = EmitFlags.AdviseOnEmitNode | + (exportVariableAdded && moduleKind !== ModuleKind.System || currentLexicalScope !== currentSourceFile ? EmitFlags.NoLeadingComments : EmitFlags.None); + + // `parameterName` is the declaration name used inside of the enum. + const parameterName = getNamespaceParameterName(node); - // (function (x_1) { - // x_1.y = ...; + // `containerName` is the expression used inside of the enum for assignments. + const containerName = getNamespaceContainerName(node); + + // (function (x) { + // x[x["y"] = 0] = "y"; + // ... // })(x || (x = {})); const moduleStatement = factory.createExpressionStatement( factory.createCallExpression( @@ -1843,29 +1732,48 @@ namespace ts { /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, - transformModuleBody(node, containerName) + isEnumDeclaration(node) ? transformEnumBody(node, containerName) : transformModuleBody(node, containerName) ), /*typeArguments*/ undefined, - [moduleArg] + [getIIFEModuleArgument(node, localName, modifierFlags)] ) ); - setOriginalNode(moduleStatement, node); - if (varAdded) { + + if (exportVariableAdded) { // If a variable was added, synthetic comments are emitted on it, not on the moduleStatement. setSyntheticLeadingComments(moduleStatement, undefined); setSyntheticTrailingComments(moduleStatement, undefined); } + setTextRange(moduleStatement, node); addEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); - // Add a DeclarationMarker for the namespace to preserve trailing comments and mark - // the end of the declaration. + // Add a DeclarationMarker for the namespace to preserve trailing comments and mark the end of the declaration. statements.push(factory.createEndOfDeclarationMarker(node)); + return statements; } + /** + * Visits a module declaration node. + * + * This function will be called any time a TypeScript namespace (ModuleDeclaration) is encountered. + * + * @param node The module declaration node. + */ + function visitModuleDeclaration(node: ModuleDeclaration): VisitResult { + if (!shouldEmitModuleDeclaration(node)) { + return factory.createNotEmittedStatement(node); + } + + Debug.assertNode(node.name, isIdentifier, "A TypeScript namespace should have an Identifier name."); + enableSubstitutionForNamespaceExports(); + + return createIIFEModule(node); + } + /** * Transforms the body of a module declaration. * diff --git a/tests/baselines/reference/exportDefaultConstEnum.js b/tests/baselines/reference/exportDefaultConstEnum.js new file mode 100644 index 0000000000000..0b5a3daec3708 --- /dev/null +++ b/tests/baselines/reference/exportDefaultConstEnum.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/exportDefaultConstEnum.ts] //// + +//// [a.ts] +export default const enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +0 /* A.A */; +1 /* A.B */; diff --git a/tests/baselines/reference/exportDefaultConstEnum.symbols b/tests/baselines/reference/exportDefaultConstEnum.symbols new file mode 100644 index 0000000000000..8ddcc557c2376 --- /dev/null +++ b/tests/baselines/reference/exportDefaultConstEnum.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default const enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 29)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 29)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 29)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultConstEnum.types b/tests/baselines/reference/exportDefaultConstEnum.types new file mode 100644 index 0000000000000..bbbbd5d614ca6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultConstEnum.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default const enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultDeclareClass.js b/tests/baselines/reference/exportDefaultDeclareClass.js new file mode 100644 index 0000000000000..8adffdfe30964 --- /dev/null +++ b/tests/baselines/reference/exportDefaultDeclareClass.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/exportDefaultDeclareClass.ts] //// + +//// [a.ts] +export default declare class C { + public foo: number; +} + +//// [b.ts] +import A from "./a" +let a: A; +a.foo + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +var a; +a.foo; diff --git a/tests/baselines/reference/exportDefaultDeclareClass.symbols b/tests/baselines/reference/exportDefaultDeclareClass.symbols new file mode 100644 index 0000000000000..e6bdf114a4aa9 --- /dev/null +++ b/tests/baselines/reference/exportDefaultDeclareClass.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/a.ts === +export default declare class C { +>C : Symbol(C, Decl(a.ts, 0, 0)) + + public foo: number; +>foo : Symbol(C.foo, Decl(a.ts, 0, 32)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +let a: A; +>a : Symbol(a, Decl(b.ts, 1, 3)) +>A : Symbol(A, Decl(b.ts, 0, 6)) + +a.foo +>a.foo : Symbol(A.foo, Decl(a.ts, 0, 32)) +>a : Symbol(a, Decl(b.ts, 1, 3)) +>foo : Symbol(A.foo, Decl(a.ts, 0, 32)) + diff --git a/tests/baselines/reference/exportDefaultDeclareClass.types b/tests/baselines/reference/exportDefaultDeclareClass.types new file mode 100644 index 0000000000000..329c38b5bf9b8 --- /dev/null +++ b/tests/baselines/reference/exportDefaultDeclareClass.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.ts === +export default declare class C { +>C : C + + public foo: number; +>foo : number +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +let a: A; +>a : A + +a.foo +>a.foo : number +>a : A +>foo : number + diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).js b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).js new file mode 100644 index 0000000000000..0c229676a54a8 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var A = {}; + exports.default = A; + (function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; + })(A); +}); +//// [b.js] +define(["require", "exports", "./a"], function (require, exports, a_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + a_1.default.A; + a_1.default.B; +}); diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).symbols b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).types b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=es5).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).js b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).js new file mode 100644 index 0000000000000..0c229676a54a8 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var A = {}; + exports.default = A; + (function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; + })(A); +}); +//// [b.js] +define(["require", "exports", "./a"], function (require, exports, a_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + a_1.default.A; + a_1.default.B; +}); diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).symbols b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).types b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=amd,target=esnext).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).js b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..20612b6089ea2 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var A = {}; +exports.default = A; +(function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; +})(A); +//// [b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var a_1 = require("./a"); +a_1.default.A; +a_1.default.B; diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).symbols b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).types b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=es5).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).js b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..0bc8d25bedf54 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var A = {}; +exports.default = A; +(function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; +})(A); +//// [b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const a_1 = require("./a"); +a_1.default.A; +a_1.default.B; diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).symbols b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).types b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=commonjs,target=esnext).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).js b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).js new file mode 100644 index 0000000000000..f01c7555a5152 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +var A = {}; +export default A; +(function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; +})(A); +//// [b.js] +import A from "./a"; +A.A; +A.B; diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).symbols b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).types b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=es5).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).js b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..f01c7555a5152 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +var A = {}; +export default A; +(function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; +})(A); +//// [b.js] +import A from "./a"; +A.A; +A.B; diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).symbols b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).types b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=esnext,target=esnext).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).js b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).js new file mode 100644 index 0000000000000..c418afad8d335 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var A; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + A = {}; + exports_1("default", A); + (function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; + })(A); + } + }; +}); +//// [b.js] +System.register(["./a"], function (exports_1, context_1) { + "use strict"; + var a_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (a_1_1) { + a_1 = a_1_1; + } + ], + execute: function () { + a_1.default.A; + a_1.default.B; + } + }; +}); diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).symbols b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).types b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=es5).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).js b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).js new file mode 100644 index 0000000000000..c418afad8d335 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/exportDefaultEnum.ts] //// + +//// [a.ts] +export default enum A { + A, + B +} + +//// [b.ts] +import A from "./a" + +A.A; +A.B; + + +//// [a.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var A; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + A = {}; + exports_1("default", A); + (function (A) { + A[A["A"] = 0] = "A"; + A[A["B"] = 1] = "B"; + })(A); + } + }; +}); +//// [b.js] +System.register(["./a"], function (exports_1, context_1) { + "use strict"; + var a_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (a_1_1) { + a_1 = a_1_1; + } + ], + execute: function () { + a_1.default.A; + a_1.default.B; + } + }; +}); diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).symbols b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).symbols new file mode 100644 index 0000000000000..de0f1003dc0b6 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + A, +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + + B +>B : Symbol(A.B, Decl(a.ts, 1, 6)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.A; +>A.A : Symbol(A.A, Decl(a.ts, 0, 23)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>A : Symbol(A.A, Decl(a.ts, 0, 23)) + +A.B; +>A.B : Symbol(A.B, Decl(a.ts, 1, 6)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>B : Symbol(A.B, Decl(a.ts, 1, 6)) + diff --git a/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).types b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).types new file mode 100644 index 0000000000000..3780128e8eb18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultEnum(module=system,target=esnext).types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +export default enum A { +>A : A + + A, +>A : A.A + + B +>B : A.B +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.A; +>A.A : A.A +>A : typeof A +>A : A.A + +A.B; +>A.B : A.B +>A : typeof A +>B : A.B + diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).js b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).js new file mode 100644 index 0000000000000..2014336da991e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var A = {}; + exports.default = A; + (function (A) { + A.Foo = 1; + })(A); +}); +//// [b.js] +define(["require", "exports", "./a"], function (require, exports, a_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + a_1.default.Foo; +}); diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).symbols b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).types b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=es5).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).js b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).js new file mode 100644 index 0000000000000..2014336da991e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var A = {}; + exports.default = A; + (function (A) { + A.Foo = 1; + })(A); +}); +//// [b.js] +define(["require", "exports", "./a"], function (require, exports, a_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + a_1.default.Foo; +}); diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).symbols b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).types b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=amd,target=esnext).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).js b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..c074ccd169d52 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var A = {}; +exports.default = A; +(function (A) { + A.Foo = 1; +})(A); +//// [b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var a_1 = require("./a"); +a_1.default.Foo; diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).symbols b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).types b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=es5).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).js b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..a8e19f6014392 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var A = {}; +exports.default = A; +(function (A) { + A.Foo = 1; +})(A); +//// [b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const a_1 = require("./a"); +a_1.default.Foo; diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).symbols b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).types b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=commonjs,target=esnext).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).js b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).js new file mode 100644 index 0000000000000..aa8b69b51ce79 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +var A = {}; +export default A; +(function (A) { + A.Foo = 1; +})(A); +//// [b.js] +import A from "./a"; +A.Foo; diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).symbols b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).types b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=es5).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).js b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..aa8b69b51ce79 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +var A = {}; +export default A; +(function (A) { + A.Foo = 1; +})(A); +//// [b.js] +import A from "./a"; +A.Foo; diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).symbols b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).types b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=esnext,target=esnext).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=es5).js b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).js new file mode 100644 index 0000000000000..0502435dd56f8 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var A; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + A = {}; + exports_1("default", A); + (function (A) { + A.Foo = 1; + })(A); + } + }; +}); +//// [b.js] +System.register(["./a"], function (exports_1, context_1) { + "use strict"; + var a_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (a_1_1) { + a_1 = a_1_1; + } + ], + execute: function () { + a_1.default.Foo; + } + }; +}); diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=es5).symbols b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=es5).types b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=es5).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).js b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).js new file mode 100644 index 0000000000000..0502435dd56f8 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" +A.Foo; + + +//// [a.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var A; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + A = {}; + exports_1("default", A); + (function (A) { + A.Foo = 1; + })(A); + } + }; +}); +//// [b.js] +System.register(["./a"], function (exports_1, context_1) { + "use strict"; + var a_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (a_1_1) { + a_1 = a_1_1; + } + ], + execute: function () { + a_1.default.Foo; + } + }; +}); diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).symbols b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).symbols new file mode 100644 index 0000000000000..aa87ab3dedb11 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo; +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) + diff --git a/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).types b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).types new file mode 100644 index 0000000000000..67ee15b1ad68e --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule(module=system,target=esnext).types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo; +>A.Foo : 1 +>A : typeof A +>Foo : 1 + diff --git a/tests/baselines/reference/exportDefaultModule.js b/tests/baselines/reference/exportDefaultModule.js new file mode 100644 index 0000000000000..0445c7d336abc --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/exportDefaultModule.ts] //// + +//// [a.ts] +export default module A { + export const Foo = 1; +} + +//// [b.ts] +import A from "./a" + + +//// [a.js] +"use strict"; +exports.__esModule = true; +exports.A = void 0; +var A; +(function (A) { + A.Foo = 1; +})(A = exports.A || (exports.A = {})); +//// [b.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/exportDefaultModule.symbols b/tests/baselines/reference/exportDefaultModule.symbols new file mode 100644 index 0000000000000..ebbe76fa10b64 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/exportDefaultModule.types b/tests/baselines/reference/exportDefaultModule.types new file mode 100644 index 0000000000000..ed144ac568937 --- /dev/null +++ b/tests/baselines/reference/exportDefaultModule.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/a.ts === +export default module A { +>A : typeof A + + export const Foo = 1; +>Foo : 1 +>1 : 1 +} + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + diff --git a/tests/baselines/reference/exportDefaultNamespace.js b/tests/baselines/reference/exportDefaultNamespace.js index 39a70d5e231d7..49fbe37cfb2c0 100644 --- a/tests/baselines/reference/exportDefaultNamespace.js +++ b/tests/baselines/reference/exportDefaultNamespace.js @@ -1,24 +1,25 @@ -//// [exportDefaultNamespace.ts] -export default function someFunc() { - return 'hello!'; +//// [tests/cases/compiler/exportDefaultNamespace.ts] //// + +//// [a.ts] +export default namespace A { + export const Foo = 1; } - -someFunc.someProp = 'yo'; + +//// [b.ts] +import A from "./a" +A.Foo -//// [exportDefaultNamespace.js] +//// [a.js] "use strict"; exports.__esModule = true; -function someFunc() { - return 'hello!'; -} -exports["default"] = someFunc; -someFunc.someProp = 'yo'; - - -//// [exportDefaultNamespace.d.ts] -declare function someFunc(): string; -declare namespace someFunc { - var someProp: string; -} -export default someFunc; +var A = {}; +exports["default"] = A; +(function (A) { + A.Foo = 1; +})(A); +//// [b.js] +"use strict"; +exports.__esModule = true; +var a_1 = require("./a"); +a_1["default"].Foo; diff --git a/tests/baselines/reference/exportDefaultNamespace.symbols b/tests/baselines/reference/exportDefaultNamespace.symbols index eee148768948b..4cdf7662634af 100644 --- a/tests/baselines/reference/exportDefaultNamespace.symbols +++ b/tests/baselines/reference/exportDefaultNamespace.symbols @@ -1,12 +1,17 @@ -=== tests/cases/conformance/declarationEmit/exportDefaultNamespace.ts === -export default function someFunc() { ->someFunc : Symbol(someFunc, Decl(exportDefaultNamespace.ts, 0, 0), Decl(exportDefaultNamespace.ts, 2, 1)) +=== tests/cases/compiler/a.ts === +export default namespace A { +>A : Symbol(A, Decl(a.ts, 0, 0)) - return 'hello!'; + export const Foo = 1; +>Foo : Symbol(Foo, Decl(a.ts, 1, 16)) } -someFunc.someProp = 'yo'; ->someFunc.someProp : Symbol(someFunc.someProp, Decl(exportDefaultNamespace.ts, 2, 1)) ->someFunc : Symbol(someFunc, Decl(exportDefaultNamespace.ts, 0, 0), Decl(exportDefaultNamespace.ts, 2, 1)) ->someProp : Symbol(someFunc.someProp, Decl(exportDefaultNamespace.ts, 2, 1)) +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +A.Foo +>A.Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) +>A : Symbol(A, Decl(b.ts, 0, 6)) +>Foo : Symbol(A.Foo, Decl(a.ts, 1, 16)) diff --git a/tests/baselines/reference/exportDefaultNamespace.types b/tests/baselines/reference/exportDefaultNamespace.types index eebf33f51f4db..0c1bc57ab8585 100644 --- a/tests/baselines/reference/exportDefaultNamespace.types +++ b/tests/baselines/reference/exportDefaultNamespace.types @@ -1,15 +1,18 @@ -=== tests/cases/conformance/declarationEmit/exportDefaultNamespace.ts === -export default function someFunc() { ->someFunc : typeof someFunc +=== tests/cases/compiler/a.ts === +export default namespace A { +>A : typeof A - return 'hello!'; ->'hello!' : "hello!" + export const Foo = 1; +>Foo : 1 +>1 : 1 } -someFunc.someProp = 'yo'; ->someFunc.someProp = 'yo' : "yo" ->someFunc.someProp : string ->someFunc : typeof someFunc ->someProp : string ->'yo' : "yo" +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : typeof A + +A.Foo +>A.Foo : 1 +>A : typeof A +>Foo : 1 diff --git a/tests/baselines/reference/exportDefaultNamespaceDeclaration.js b/tests/baselines/reference/exportDefaultNamespaceDeclaration.js new file mode 100644 index 0000000000000..13ab33f40f2fe --- /dev/null +++ b/tests/baselines/reference/exportDefaultNamespaceDeclaration.js @@ -0,0 +1,24 @@ +//// [exportDefaultNamespaceDeclaration.ts] +export default function someFunc() { + return 'hello!'; +} + +someFunc.someProp = 'yo'; + + +//// [exportDefaultNamespaceDeclaration.js] +"use strict"; +exports.__esModule = true; +function someFunc() { + return 'hello!'; +} +exports["default"] = someFunc; +someFunc.someProp = 'yo'; + + +//// [exportDefaultNamespaceDeclaration.d.ts] +declare function someFunc(): string; +declare namespace someFunc { + var someProp: string; +} +export default someFunc; diff --git a/tests/baselines/reference/exportDefaultNamespaceDeclaration.symbols b/tests/baselines/reference/exportDefaultNamespaceDeclaration.symbols new file mode 100644 index 0000000000000..98ed78d1f20b2 --- /dev/null +++ b/tests/baselines/reference/exportDefaultNamespaceDeclaration.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/declarationEmit/exportDefaultNamespaceDeclaration.ts === +export default function someFunc() { +>someFunc : Symbol(someFunc, Decl(exportDefaultNamespaceDeclaration.ts, 0, 0), Decl(exportDefaultNamespaceDeclaration.ts, 2, 1)) + + return 'hello!'; +} + +someFunc.someProp = 'yo'; +>someFunc.someProp : Symbol(someFunc.someProp, Decl(exportDefaultNamespaceDeclaration.ts, 2, 1)) +>someFunc : Symbol(someFunc, Decl(exportDefaultNamespaceDeclaration.ts, 0, 0), Decl(exportDefaultNamespaceDeclaration.ts, 2, 1)) +>someProp : Symbol(someFunc.someProp, Decl(exportDefaultNamespaceDeclaration.ts, 2, 1)) + diff --git a/tests/baselines/reference/exportDefaultNamespaceDeclaration.types b/tests/baselines/reference/exportDefaultNamespaceDeclaration.types new file mode 100644 index 0000000000000..bd8b5f1524041 --- /dev/null +++ b/tests/baselines/reference/exportDefaultNamespaceDeclaration.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/declarationEmit/exportDefaultNamespaceDeclaration.ts === +export default function someFunc() { +>someFunc : typeof someFunc + + return 'hello!'; +>'hello!' : "hello!" +} + +someFunc.someProp = 'yo'; +>someFunc.someProp = 'yo' : "yo" +>someFunc.someProp : string +>someFunc : typeof someFunc +>someProp : string +>'yo' : "yo" + diff --git a/tests/baselines/reference/exportDefaultType.js b/tests/baselines/reference/exportDefaultType.js new file mode 100644 index 0000000000000..4cde1d574230b --- /dev/null +++ b/tests/baselines/reference/exportDefaultType.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/exportDefaultType.ts] //// + +//// [a.ts] +export default type A = number; + +//// [b.ts] +import A from "./a" +let a: A; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +var a; diff --git a/tests/baselines/reference/exportDefaultType.symbols b/tests/baselines/reference/exportDefaultType.symbols new file mode 100644 index 0000000000000..d4ada6d8dd90e --- /dev/null +++ b/tests/baselines/reference/exportDefaultType.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/a.ts === +export default type A = number; +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : Symbol(A, Decl(b.ts, 0, 6)) + +let a: A; +>a : Symbol(a, Decl(b.ts, 1, 3)) +>A : Symbol(A, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/exportDefaultType.types b/tests/baselines/reference/exportDefaultType.types new file mode 100644 index 0000000000000..f1240f022d9f0 --- /dev/null +++ b/tests/baselines/reference/exportDefaultType.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/a.ts === +export default type A = number; +>A : number + +=== tests/cases/compiler/b.ts === +import A from "./a" +>A : any + +let a: A; +>a : number + diff --git a/tests/cases/compiler/exportDefaultConstEnum.ts b/tests/cases/compiler/exportDefaultConstEnum.ts new file mode 100644 index 0000000000000..7a44300f896f5 --- /dev/null +++ b/tests/cases/compiler/exportDefaultConstEnum.ts @@ -0,0 +1,11 @@ +// @filename: a.ts +export default const enum A { + A, + B +} + +// @filename: b.ts +import A from "./a" + +A.A; +A.B; diff --git a/tests/cases/compiler/exportDefaultDeclareClass.ts b/tests/cases/compiler/exportDefaultDeclareClass.ts new file mode 100644 index 0000000000000..93aa146aa6832 --- /dev/null +++ b/tests/cases/compiler/exportDefaultDeclareClass.ts @@ -0,0 +1,9 @@ +// @filename: a.ts +export default declare class C { + public foo: number; +} + +// @filename: b.ts +import A from "./a" +let a: A; +a.foo diff --git a/tests/cases/compiler/exportDefaultEnum.ts b/tests/cases/compiler/exportDefaultEnum.ts new file mode 100644 index 0000000000000..11a62ac3b3ab6 --- /dev/null +++ b/tests/cases/compiler/exportDefaultEnum.ts @@ -0,0 +1,14 @@ +// @module: esnext, commonjs, amd, system +// @target: es5, esnext + +// @filename: a.ts +export default enum A { + A, + B +} + +// @filename: b.ts +import A from "./a" + +A.A; +A.B; diff --git a/tests/cases/compiler/exportDefaultModule.ts b/tests/cases/compiler/exportDefaultModule.ts new file mode 100644 index 0000000000000..417d9f3838f08 --- /dev/null +++ b/tests/cases/compiler/exportDefaultModule.ts @@ -0,0 +1,11 @@ +// @module: esnext, commonjs, amd, system +// @target: es5, esnext + +// @filename: a.ts +export default module A { + export const Foo = 1; +} + +// @filename: b.ts +import A from "./a" +A.Foo; diff --git a/tests/cases/compiler/exportDefaultNamespace.ts b/tests/cases/compiler/exportDefaultNamespace.ts new file mode 100644 index 0000000000000..c5e6565a76818 --- /dev/null +++ b/tests/cases/compiler/exportDefaultNamespace.ts @@ -0,0 +1,8 @@ +// @filename: a.ts +export default namespace A { + export const Foo = 1; +} + +// @filename: b.ts +import A from "./a" +A.Foo diff --git a/tests/cases/compiler/exportDefaultType.ts b/tests/cases/compiler/exportDefaultType.ts new file mode 100644 index 0000000000000..19992125a1588 --- /dev/null +++ b/tests/cases/compiler/exportDefaultType.ts @@ -0,0 +1,8 @@ +// @strict: true + +// @filename: a.ts +export default type A = number; + +// @filename: b.ts +import A from "./a" +let a: A; diff --git a/tests/cases/conformance/declarationEmit/exportDefaultNamespace.ts b/tests/cases/conformance/declarationEmit/exportDefaultNamespaceDeclaration.ts similarity index 100% rename from tests/cases/conformance/declarationEmit/exportDefaultNamespace.ts rename to tests/cases/conformance/declarationEmit/exportDefaultNamespaceDeclaration.ts