Merge branch 'exportEquals' of https://github.com/Microsoft/TypeScript into exportEquals
This commit is contained in:
commit
d47445b175
|
@ -532,11 +532,11 @@ module ts {
|
|||
case SyntaxKind.ExportAssignment:
|
||||
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
|
||||
// An export default clause with an identifier exports all meanings of that identifier
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
}
|
||||
else {
|
||||
// An export default clause with an expression exports a value
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
}
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
|
|
|
@ -543,6 +543,24 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
// This function creates a synthetic symbol that combines the value side of one symbol with the
|
||||
// type/namespace side of another symbol. Consider this example:
|
||||
//
|
||||
// declare module graphics {
|
||||
// interface Point {
|
||||
// x: number;
|
||||
// y: number;
|
||||
// }
|
||||
// }
|
||||
// declare var graphics: {
|
||||
// Point: new (x: number, y: number) => graphics.Point;
|
||||
// }
|
||||
// declare module "graphics" {
|
||||
// export = graphics;
|
||||
// }
|
||||
//
|
||||
// An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point'
|
||||
// property with the type/namespace side interface 'Point'.
|
||||
function combineValueAndTypeSymbols(valueSymbol: Symbol, typeSymbol: Symbol): Symbol {
|
||||
if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) {
|
||||
return valueSymbol;
|
||||
|
@ -607,7 +625,7 @@ module ts {
|
|||
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
|
||||
}
|
||||
|
||||
function getTargetOfImportDeclaration(node: Declaration): Symbol {
|
||||
function getTargetOfAliasDeclaration(node: Declaration): Symbol {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return getTargetOfImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
|
@ -634,7 +652,7 @@ module ts {
|
|||
if (!links.target) {
|
||||
links.target = resolvingSymbol;
|
||||
let node = getDeclarationOfAliasSymbol(symbol);
|
||||
let target = getTargetOfImportDeclaration(node);
|
||||
let target = getTargetOfAliasDeclaration(node);
|
||||
if (links.target === resolvingSymbol) {
|
||||
links.target = target || unknownSymbol;
|
||||
}
|
||||
|
@ -788,10 +806,15 @@ module ts {
|
|||
error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
|
||||
}
|
||||
|
||||
// An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
|
||||
// and an external module with no 'export =' declaration resolves to the module itself.
|
||||
function resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol {
|
||||
return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol;
|
||||
}
|
||||
|
||||
// An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export ='
|
||||
// references a symbol that is at least declared as a module or a variable. The target of the 'export =' may
|
||||
// combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable).
|
||||
function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression): Symbol {
|
||||
let symbol = resolveExternalModuleSymbol(moduleSymbol);
|
||||
if (symbol && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) {
|
||||
|
@ -10274,30 +10297,6 @@ module ts {
|
|||
return emptyArray;
|
||||
}
|
||||
|
||||
//function hasExportedMembers(moduleSymbol: Symbol) {
|
||||
// let declarations = moduleSymbol.declarations;
|
||||
// for (let current of declarations) {
|
||||
// let statements = getModuleStatements(current);
|
||||
// for (let node of statements) {
|
||||
// if (node.kind === SyntaxKind.ExportDeclaration) {
|
||||
// let exportClause = (<ExportDeclaration>node).exportClause;
|
||||
// if (!exportClause) {
|
||||
// return true;
|
||||
// }
|
||||
// let specifiers = exportClause.elements;
|
||||
// for (let specifier of specifiers) {
|
||||
// if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (node.kind !== SyntaxKind.ExportAssignment && node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
function hasExportedMembers(moduleSymbol: Symbol) {
|
||||
for (var id in moduleSymbol.exports) {
|
||||
if (id !== "export=") {
|
||||
|
|
|
@ -3668,10 +3668,6 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function isNakedImport(node: ImportDeclaration | ImportEqualsDeclaration) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
|
||||
}
|
||||
|
||||
function emitExportImportAssignments(node: Node) {
|
||||
if (isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
|
||||
emitExportMemberAssignments(<Identifier>(<Declaration>node).name);
|
||||
|
@ -3749,30 +3745,48 @@ module ts {
|
|||
|
||||
function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) {
|
||||
if (contains(externalImports, node)) {
|
||||
let exportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
let namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
|
||||
if (compilerOptions.module !== ModuleKind.AMD) {
|
||||
emitLeadingComments(node);
|
||||
emitStart(node);
|
||||
if (namespaceDeclaration) {
|
||||
if (!exportedImport) write("var ");
|
||||
let isDefaultImport = node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause && !!(<ImportDeclaration>node).importClause.name;
|
||||
if (namespaceDeclaration && !isDefaultImport) {
|
||||
// import x = require("foo")
|
||||
// import * as x from "foo"
|
||||
if (!isExportedImport) write("var ");
|
||||
emitModuleMemberName(namespaceDeclaration);
|
||||
write(" = ");
|
||||
}
|
||||
else if (!isNakedImport(node)) {
|
||||
write("var ");
|
||||
write(resolver.getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
write(" = ");
|
||||
else {
|
||||
// import "foo"
|
||||
// import x from "foo"
|
||||
// import { x, y } from "foo"
|
||||
// import d, * as x from "foo"
|
||||
// import d, { x, y } from "foo"
|
||||
let isNakedImport = SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
|
||||
if (!isNakedImport) {
|
||||
write("var ");
|
||||
write(resolver.getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
write(" = ");
|
||||
}
|
||||
}
|
||||
emitRequire(getExternalModuleName(node));
|
||||
if (namespaceDeclaration && isDefaultImport) {
|
||||
// import d, * as x from "foo"
|
||||
write(", ");
|
||||
emitModuleMemberName(namespaceDeclaration);
|
||||
write(" = ");
|
||||
write(resolver.getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
}
|
||||
write(";");
|
||||
emitEnd(node);
|
||||
emitExportImportAssignments(node);
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
else {
|
||||
if (exportedImport) {
|
||||
if (isExportedImport) {
|
||||
emitModuleMemberName(namespaceDeclaration);
|
||||
write(" = ");
|
||||
emit(namespaceDeclaration.name);
|
||||
|
|
|
@ -848,7 +848,7 @@ module ts {
|
|||
node.kind === SyntaxKind.NamespaceImport ||
|
||||
node.kind === SyntaxKind.ImportSpecifier ||
|
||||
node.kind === SyntaxKind.ExportSpecifier ||
|
||||
node.kind === SyntaxKind.ExportAssignment;
|
||||
node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
export function getClassBaseTypeNode(node: ClassDeclaration) {
|
||||
|
|
304
tests/baselines/reference/es6ExportEqualsInterop.errors.txt
Normal file
304
tests/baselines/reference/es6ExportEqualsInterop.errors.txt
Normal file
|
@ -0,0 +1,304 @@
|
|||
tests/cases/compiler/main.ts(15,1): error TS2304: Cannot find name 'z1'.
|
||||
tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'.
|
||||
tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'.
|
||||
tests/cases/compiler/main.ts(27,8): error TS1192: External module '"interface"' has no default export.
|
||||
tests/cases/compiler/main.ts(28,8): error TS1192: External module '"variable"' has no default export.
|
||||
tests/cases/compiler/main.ts(29,8): error TS1192: External module '"interface-variable"' has no default export.
|
||||
tests/cases/compiler/main.ts(30,8): error TS1192: External module '"module"' has no default export.
|
||||
tests/cases/compiler/main.ts(31,8): error TS1192: External module '"interface-module"' has no default export.
|
||||
tests/cases/compiler/main.ts(32,8): error TS1192: External module '"variable-module"' has no default export.
|
||||
tests/cases/compiler/main.ts(33,8): error TS1192: External module '"function"' has no default export.
|
||||
tests/cases/compiler/main.ts(34,8): error TS1192: External module '"function-module"' has no default export.
|
||||
tests/cases/compiler/main.ts(35,8): error TS1192: External module '"class"' has no default export.
|
||||
tests/cases/compiler/main.ts(36,8): error TS1192: External module '"class-module"' has no default export.
|
||||
tests/cases/compiler/main.ts(39,21): error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(45,21): error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(47,21): error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(62,25): error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(68,25): error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(70,25): error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(85,25): error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(91,25): error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(93,25): error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
tests/cases/compiler/main.ts(97,15): error TS2497: External module '"interface"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(98,15): error TS2497: External module '"variable"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(99,15): error TS2497: External module '"interface-variable"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(100,15): error TS2497: External module '"module"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(101,15): error TS2497: External module '"interface-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(102,15): error TS2497: External module '"variable-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(103,15): error TS2497: External module '"function"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(104,15): error TS2497: External module '"function-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(105,15): error TS2497: External module '"class"' uses 'export =' and cannot be used with 'export *'.
|
||||
tests/cases/compiler/main.ts(106,15): error TS2497: External module '"class-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/main.ts (32 errors) ====
|
||||
/// <reference path="modules.d.ts"/>
|
||||
|
||||
// import-equals
|
||||
import z1 = require("interface");
|
||||
import z2 = require("variable");
|
||||
import z3 = require("interface-variable");
|
||||
import z4 = require("module");
|
||||
import z5 = require("interface-module");
|
||||
import z6 = require("variable-module");
|
||||
import z7 = require("function");
|
||||
import z8 = require("function-module");
|
||||
import z9 = require("class");
|
||||
import z0 = require("class-module");
|
||||
|
||||
z1.a;
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'z1'.
|
||||
z2.a;
|
||||
z3.a;
|
||||
z4.a;
|
||||
z5.a;
|
||||
z6.a;
|
||||
z7.a;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type '() => any'.
|
||||
z8.a;
|
||||
z9.a;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'typeof Foo'.
|
||||
z0.a;
|
||||
|
||||
// default import
|
||||
import x1 from "interface";
|
||||
~~
|
||||
!!! error TS1192: External module '"interface"' has no default export.
|
||||
import x2 from "variable";
|
||||
~~
|
||||
!!! error TS1192: External module '"variable"' has no default export.
|
||||
import x3 from "interface-variable";
|
||||
~~
|
||||
!!! error TS1192: External module '"interface-variable"' has no default export.
|
||||
import x4 from "module";
|
||||
~~
|
||||
!!! error TS1192: External module '"module"' has no default export.
|
||||
import x5 from "interface-module";
|
||||
~~
|
||||
!!! error TS1192: External module '"interface-module"' has no default export.
|
||||
import x6 from "variable-module";
|
||||
~~
|
||||
!!! error TS1192: External module '"variable-module"' has no default export.
|
||||
import x7 from "function";
|
||||
~~
|
||||
!!! error TS1192: External module '"function"' has no default export.
|
||||
import x8 from "function-module";
|
||||
~~
|
||||
!!! error TS1192: External module '"function-module"' has no default export.
|
||||
import x9 from "class";
|
||||
~~
|
||||
!!! error TS1192: External module '"class"' has no default export.
|
||||
import x0 from "class-module";
|
||||
~~
|
||||
!!! error TS1192: External module '"class-module"' has no default export.
|
||||
|
||||
// namespace import
|
||||
import * as y1 from "interface";
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import * as y2 from "variable";
|
||||
import * as y3 from "interface-variable";
|
||||
import * as y4 from "module";
|
||||
import * as y5 from "interface-module";
|
||||
import * as y6 from "variable-module";
|
||||
import * as y7 from "function";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import * as y8 from "function-module";
|
||||
import * as y9 from "class";
|
||||
~~~~~~~
|
||||
!!! error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import * as y0 from "class-module";
|
||||
|
||||
y1.a;
|
||||
y2.a;
|
||||
y3.a;
|
||||
y4.a;
|
||||
y5.a;
|
||||
y6.a;
|
||||
y7.a;
|
||||
y8.a;
|
||||
y9.a;
|
||||
y0.a;
|
||||
|
||||
// named import
|
||||
import { a as a1 } from "interface";
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import { a as a2 } from "variable";
|
||||
import { a as a3 } from "interface-variable";
|
||||
import { a as a4 } from "module";
|
||||
import { a as a5 } from "interface-module";
|
||||
import { a as a6 } from "variable-module";
|
||||
import { a as a7 } from "function";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import { a as a8 } from "function-module";
|
||||
import { a as a9 } from "class";
|
||||
~~~~~~~
|
||||
!!! error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
import { a as a0 } from "class-module";
|
||||
|
||||
a1;
|
||||
a2;
|
||||
a3;
|
||||
a4;
|
||||
a5;
|
||||
a6;
|
||||
a7;
|
||||
a8;
|
||||
a9;
|
||||
a0;
|
||||
|
||||
// named export
|
||||
export { a as a1 } from "interface";
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2496: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
export { a as a2 } from "variable";
|
||||
export { a as a3 } from "interface-variable";
|
||||
export { a as a4 } from "module";
|
||||
export { a as a5 } from "interface-module";
|
||||
export { a as a6 } from "variable-module";
|
||||
export { a as a7 } from "function";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2496: External module '"function"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
export { a as a8 } from "function-module";
|
||||
export { a as a9 } from "class";
|
||||
~~~~~~~
|
||||
!!! error TS2496: External module '"class"' resolves to a non-module entity and cannot be imported using this construct.
|
||||
export { a as a0 } from "class-module";
|
||||
|
||||
// export-star
|
||||
export * from "interface";
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"interface"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "variable";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2497: External module '"variable"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "interface-variable";
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"interface-variable"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "module";
|
||||
~~~~~~~~
|
||||
!!! error TS2497: External module '"module"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "interface-module";
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"interface-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "variable-module";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"variable-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "function";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2497: External module '"function"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "function-module";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"function-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "class";
|
||||
~~~~~~~
|
||||
!!! error TS2497: External module '"class"' uses 'export =' and cannot be used with 'export *'.
|
||||
export * from "class-module";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2497: External module '"class-module"' uses 'export =' and cannot be used with 'export *'.
|
||||
|
||||
==== tests/cases/compiler/modules.d.ts (0 errors) ====
|
||||
|
||||
declare module "interface" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable" {
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-variable" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "module" {
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-module" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable-module" {
|
||||
module Foo {
|
||||
interface Bar {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "function" {
|
||||
function foo();
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "function-module" {
|
||||
function foo();
|
||||
module foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "class" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "class-module" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
301
tests/baselines/reference/es6ExportEqualsInterop.js
Normal file
301
tests/baselines/reference/es6ExportEqualsInterop.js
Normal file
|
@ -0,0 +1,301 @@
|
|||
//// [tests/cases/compiler/es6ExportEqualsInterop.ts] ////
|
||||
|
||||
//// [modules.d.ts]
|
||||
|
||||
declare module "interface" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable" {
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-variable" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "module" {
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-module" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable-module" {
|
||||
module Foo {
|
||||
interface Bar {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "function" {
|
||||
function foo();
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "function-module" {
|
||||
function foo();
|
||||
module foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "class" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "class-module" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
//// [main.ts]
|
||||
/// <reference path="modules.d.ts"/>
|
||||
|
||||
// import-equals
|
||||
import z1 = require("interface");
|
||||
import z2 = require("variable");
|
||||
import z3 = require("interface-variable");
|
||||
import z4 = require("module");
|
||||
import z5 = require("interface-module");
|
||||
import z6 = require("variable-module");
|
||||
import z7 = require("function");
|
||||
import z8 = require("function-module");
|
||||
import z9 = require("class");
|
||||
import z0 = require("class-module");
|
||||
|
||||
z1.a;
|
||||
z2.a;
|
||||
z3.a;
|
||||
z4.a;
|
||||
z5.a;
|
||||
z6.a;
|
||||
z7.a;
|
||||
z8.a;
|
||||
z9.a;
|
||||
z0.a;
|
||||
|
||||
// default import
|
||||
import x1 from "interface";
|
||||
import x2 from "variable";
|
||||
import x3 from "interface-variable";
|
||||
import x4 from "module";
|
||||
import x5 from "interface-module";
|
||||
import x6 from "variable-module";
|
||||
import x7 from "function";
|
||||
import x8 from "function-module";
|
||||
import x9 from "class";
|
||||
import x0 from "class-module";
|
||||
|
||||
// namespace import
|
||||
import * as y1 from "interface";
|
||||
import * as y2 from "variable";
|
||||
import * as y3 from "interface-variable";
|
||||
import * as y4 from "module";
|
||||
import * as y5 from "interface-module";
|
||||
import * as y6 from "variable-module";
|
||||
import * as y7 from "function";
|
||||
import * as y8 from "function-module";
|
||||
import * as y9 from "class";
|
||||
import * as y0 from "class-module";
|
||||
|
||||
y1.a;
|
||||
y2.a;
|
||||
y3.a;
|
||||
y4.a;
|
||||
y5.a;
|
||||
y6.a;
|
||||
y7.a;
|
||||
y8.a;
|
||||
y9.a;
|
||||
y0.a;
|
||||
|
||||
// named import
|
||||
import { a as a1 } from "interface";
|
||||
import { a as a2 } from "variable";
|
||||
import { a as a3 } from "interface-variable";
|
||||
import { a as a4 } from "module";
|
||||
import { a as a5 } from "interface-module";
|
||||
import { a as a6 } from "variable-module";
|
||||
import { a as a7 } from "function";
|
||||
import { a as a8 } from "function-module";
|
||||
import { a as a9 } from "class";
|
||||
import { a as a0 } from "class-module";
|
||||
|
||||
a1;
|
||||
a2;
|
||||
a3;
|
||||
a4;
|
||||
a5;
|
||||
a6;
|
||||
a7;
|
||||
a8;
|
||||
a9;
|
||||
a0;
|
||||
|
||||
// named export
|
||||
export { a as a1 } from "interface";
|
||||
export { a as a2 } from "variable";
|
||||
export { a as a3 } from "interface-variable";
|
||||
export { a as a4 } from "module";
|
||||
export { a as a5 } from "interface-module";
|
||||
export { a as a6 } from "variable-module";
|
||||
export { a as a7 } from "function";
|
||||
export { a as a8 } from "function-module";
|
||||
export { a as a9 } from "class";
|
||||
export { a as a0 } from "class-module";
|
||||
|
||||
// export-star
|
||||
export * from "interface";
|
||||
export * from "variable";
|
||||
export * from "interface-variable";
|
||||
export * from "module";
|
||||
export * from "interface-module";
|
||||
export * from "variable-module";
|
||||
export * from "function";
|
||||
export * from "function-module";
|
||||
export * from "class";
|
||||
export * from "class-module";
|
||||
|
||||
|
||||
//// [main.js]
|
||||
/// <reference path="modules.d.ts"/>
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
var z2 = require("variable");
|
||||
var z3 = require("interface-variable");
|
||||
var z4 = require("module");
|
||||
var z5 = require("interface-module");
|
||||
var z6 = require("variable-module");
|
||||
var z7 = require("function");
|
||||
var z8 = require("function-module");
|
||||
var z9 = require("class");
|
||||
var z0 = require("class-module");
|
||||
z1.a;
|
||||
z2.a;
|
||||
z3.a;
|
||||
z4.a;
|
||||
z5.a;
|
||||
z6.a;
|
||||
z7.a;
|
||||
z8.a;
|
||||
z9.a;
|
||||
z0.a;
|
||||
// namespace import
|
||||
var y1 = require("interface");
|
||||
var y2 = require("variable");
|
||||
var y3 = require("interface-variable");
|
||||
var y4 = require("module");
|
||||
var y5 = require("interface-module");
|
||||
var y6 = require("variable-module");
|
||||
var y7 = require("function");
|
||||
var y8 = require("function-module");
|
||||
var y9 = require("class");
|
||||
var y0 = require("class-module");
|
||||
y1.a;
|
||||
y2.a;
|
||||
y3.a;
|
||||
y4.a;
|
||||
y5.a;
|
||||
y6.a;
|
||||
y7.a;
|
||||
y8.a;
|
||||
y9.a;
|
||||
y0.a;
|
||||
// named import
|
||||
var _interface_2 = require("interface");
|
||||
var _variable_2 = require("variable");
|
||||
var _interface_variable_2 = require("interface-variable");
|
||||
var _module_2 = require("module");
|
||||
var _interface_module_2 = require("interface-module");
|
||||
var _variable_module_2 = require("variable-module");
|
||||
var _function_2 = require("function");
|
||||
var _function_module_2 = require("function-module");
|
||||
var _class_2 = require("class");
|
||||
var _class_module_2 = require("class-module");
|
||||
_interface_2.a;
|
||||
_variable_2.a;
|
||||
_interface_variable_2.a;
|
||||
_module_2.a;
|
||||
_interface_module_2.a;
|
||||
_variable_module_2.a;
|
||||
_function_2.a;
|
||||
_function_module_2.a;
|
||||
_class_2.a;
|
||||
_class_module_2.a;
|
||||
// named export
|
||||
var _variable_3 = require("variable");
|
||||
exports.a2 = _variable_3.a;
|
||||
var _interface_variable_3 = require("interface-variable");
|
||||
exports.a3 = _interface_variable_3.a;
|
||||
var _module_3 = require("module");
|
||||
exports.a4 = _module_3.a;
|
||||
var _interface_module_3 = require("interface-module");
|
||||
exports.a5 = _interface_module_3.a;
|
||||
var _variable_module_3 = require("variable-module");
|
||||
exports.a6 = _variable_module_3.a;
|
||||
var _function_module_3 = require("function-module");
|
||||
exports.a8 = _function_module_3.a;
|
||||
var _class_module_3 = require("class-module");
|
||||
exports.a0 = _class_module_3.a;
|
||||
// export-star
|
||||
__export(require("interface"));
|
||||
__export(require("variable"));
|
||||
__export(require("interface-variable"));
|
||||
__export(require("module"));
|
||||
__export(require("interface-module"));
|
||||
__export(require("variable-module"));
|
||||
__export(require("function"));
|
||||
__export(require("function-module"));
|
||||
__export(require("class"));
|
||||
__export(require("class-module"));
|
33
tests/baselines/reference/exportStar-amd.errors.txt
Normal file
33
tests/baselines/reference/exportStar-amd.errors.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
|
||||
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t3.ts (0 errors) ====
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ====
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
~~~~~
|
||||
!!! error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
||||
|
69
tests/baselines/reference/exportStar-amd.js
Normal file
69
tests/baselines/reference/exportStar-amd.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportStar-amd.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
//// [t2.ts]
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
//// [t3.ts]
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
//// [t4.ts]
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
//// [main.ts]
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.x = 1;
|
||||
exports.y = 2;
|
||||
});
|
||||
//// [t2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.default = "hello";
|
||||
function foo() {
|
||||
}
|
||||
exports.foo = foo;
|
||||
});
|
||||
//// [t3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var x = "x";
|
||||
exports.x = x;
|
||||
var y = "y";
|
||||
exports.y = y;
|
||||
var z = "z";
|
||||
exports.z = z;
|
||||
});
|
||||
//// [t4.js]
|
||||
define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, _t1, _t2, _t3) {
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
__export(_t1);
|
||||
__export(_t2);
|
||||
__export(_t3);
|
||||
});
|
||||
//// [main.js]
|
||||
define(["require", "exports", "./t4"], function (require, exports, _t4) {
|
||||
_t4.default;
|
||||
_t4.x;
|
||||
_t4.y;
|
||||
_t4.z;
|
||||
_t4.foo;
|
||||
});
|
33
tests/baselines/reference/exportStar.errors.txt
Normal file
33
tests/baselines/reference/exportStar.errors.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
|
||||
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t3.ts (0 errors) ====
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ====
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
~~~~~
|
||||
!!! error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
||||
|
60
tests/baselines/reference/exportStar.js
Normal file
60
tests/baselines/reference/exportStar.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportStar.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
//// [t2.ts]
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
//// [t3.ts]
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
//// [t4.ts]
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
//// [main.ts]
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
exports.x = 1;
|
||||
exports.y = 2;
|
||||
//// [t2.js]
|
||||
exports.default = "hello";
|
||||
function foo() {
|
||||
}
|
||||
exports.foo = foo;
|
||||
//// [t3.js]
|
||||
var x = "x";
|
||||
exports.x = x;
|
||||
var y = "y";
|
||||
exports.y = y;
|
||||
var z = "z";
|
||||
exports.z = z;
|
||||
//// [t4.js]
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
__export(require("./t1"));
|
||||
__export(require("./t2"));
|
||||
__export(require("./t3"));
|
||||
//// [main.js]
|
||||
var _t4 = require("./t4");
|
||||
_t4.default;
|
||||
_t4.x;
|
||||
_t4.y;
|
||||
_t4.z;
|
||||
_t4.foo;
|
82
tests/baselines/reference/exportsAndImports1-amd.js
Normal file
82
tests/baselines/reference/exportsAndImports1-amd.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports1-amd.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
var v = 1;
|
||||
function f() { }
|
||||
class C {
|
||||
}
|
||||
interface I {
|
||||
}
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
const enum D {
|
||||
A, B, C
|
||||
}
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
import a = M.x;
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
//// [t2.ts]
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var v = 1;
|
||||
exports.v = v;
|
||||
function f() {
|
||||
}
|
||||
exports.f = f;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
E[E["C"] = 2] = "C";
|
||||
})(E || (E = {}));
|
||||
exports.E = E;
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x;
|
||||
})(M || (M = {}));
|
||||
exports.M = M;
|
||||
var a = M.x;
|
||||
exports.a = a;
|
||||
});
|
||||
//// [t2.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.v = _t1.v;
|
||||
exports.f = _t1.f;
|
||||
exports.C = _t1.C;
|
||||
exports.E = _t1.E;
|
||||
exports.M = _t1.M;
|
||||
exports.a = _t1.a;
|
||||
});
|
||||
//// [t3.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.v = _t1.v;
|
||||
exports.f = _t1.f;
|
||||
exports.C = _t1.C;
|
||||
exports.E = _t1.E;
|
||||
exports.M = _t1.M;
|
||||
exports.a = _t1.a;
|
||||
});
|
101
tests/baselines/reference/exportsAndImports1-amd.types
Normal file
101
tests/baselines/reference/exportsAndImports1-amd.types
Normal file
|
@ -0,0 +1,101 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
var v = 1;
|
||||
>v : number
|
||||
|
||||
function f() { }
|
||||
>f : () => void
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
}
|
||||
interface I {
|
||||
>I : I
|
||||
}
|
||||
enum E {
|
||||
>E : E
|
||||
|
||||
A, B, C
|
||||
>A : E
|
||||
>B : E
|
||||
>C : E
|
||||
}
|
||||
const enum D {
|
||||
>D : D
|
||||
|
||||
A, B, C
|
||||
>A : D
|
||||
>B : D
|
||||
>C : D
|
||||
}
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
export var x;
|
||||
>x : any
|
||||
}
|
||||
module N {
|
||||
>N : unknown
|
||||
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
>T : number
|
||||
|
||||
import a = M.x;
|
||||
>a : any
|
||||
>M : typeof M
|
||||
>x : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
78
tests/baselines/reference/exportsAndImports1.js
Normal file
78
tests/baselines/reference/exportsAndImports1.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports1.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
var v = 1;
|
||||
function f() { }
|
||||
class C {
|
||||
}
|
||||
interface I {
|
||||
}
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
const enum D {
|
||||
A, B, C
|
||||
}
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
import a = M.x;
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
//// [t2.ts]
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
var v = 1;
|
||||
exports.v = v;
|
||||
function f() {
|
||||
}
|
||||
exports.f = f;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
E[E["C"] = 2] = "C";
|
||||
})(E || (E = {}));
|
||||
exports.E = E;
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x;
|
||||
})(M || (M = {}));
|
||||
exports.M = M;
|
||||
var a = M.x;
|
||||
exports.a = a;
|
||||
//// [t2.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.v = _t1.v;
|
||||
exports.f = _t1.f;
|
||||
exports.C = _t1.C;
|
||||
exports.E = _t1.E;
|
||||
exports.M = _t1.M;
|
||||
exports.a = _t1.a;
|
||||
//// [t3.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.v = _t1.v;
|
||||
exports.f = _t1.f;
|
||||
exports.C = _t1.C;
|
||||
exports.E = _t1.E;
|
||||
exports.M = _t1.M;
|
||||
exports.a = _t1.a;
|
101
tests/baselines/reference/exportsAndImports1.types
Normal file
101
tests/baselines/reference/exportsAndImports1.types
Normal file
|
@ -0,0 +1,101 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
var v = 1;
|
||||
>v : number
|
||||
|
||||
function f() { }
|
||||
>f : () => void
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
}
|
||||
interface I {
|
||||
>I : I
|
||||
}
|
||||
enum E {
|
||||
>E : E
|
||||
|
||||
A, B, C
|
||||
>A : E
|
||||
>B : E
|
||||
>C : E
|
||||
}
|
||||
const enum D {
|
||||
>D : D
|
||||
|
||||
A, B, C
|
||||
>A : D
|
||||
>B : D
|
||||
>C : D
|
||||
}
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
export var x;
|
||||
>x : any
|
||||
}
|
||||
module N {
|
||||
>N : unknown
|
||||
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
>T : number
|
||||
|
||||
import a = M.x;
|
||||
>a : any
|
||||
>M : typeof M
|
||||
>x : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
30
tests/baselines/reference/exportsAndImports2-amd.js
Normal file
30
tests/baselines/reference/exportsAndImports2-amd.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports2-amd.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var x = "x";
|
||||
export var y = "y";
|
||||
|
||||
//// [t2.ts]
|
||||
export { x as y, y as x } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { x, y } from "./t1";
|
||||
export { x as y, y as x };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.x = "x";
|
||||
exports.y = "y";
|
||||
});
|
||||
//// [t2.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.y = _t1.x;
|
||||
exports.x = _t1.y;
|
||||
});
|
||||
//// [t3.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.y = _t1.x;
|
||||
exports.x = _t1.y;
|
||||
});
|
26
tests/baselines/reference/exportsAndImports2-amd.types
Normal file
26
tests/baselines/reference/exportsAndImports2-amd.types
Normal file
|
@ -0,0 +1,26 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
export var x = "x";
|
||||
>x : string
|
||||
|
||||
export var y = "y";
|
||||
>y : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { x as y, y as x } from "./t1";
|
||||
>x : string
|
||||
>y : string
|
||||
>y : string
|
||||
>x : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { x, y } from "./t1";
|
||||
>x : string
|
||||
>y : string
|
||||
|
||||
export { x as y, y as x };
|
||||
>x : string
|
||||
>y : string
|
||||
>y : string
|
||||
>x : string
|
||||
|
26
tests/baselines/reference/exportsAndImports2.js
Normal file
26
tests/baselines/reference/exportsAndImports2.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports2.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var x = "x";
|
||||
export var y = "y";
|
||||
|
||||
//// [t2.ts]
|
||||
export { x as y, y as x } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { x, y } from "./t1";
|
||||
export { x as y, y as x };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
exports.x = "x";
|
||||
exports.y = "y";
|
||||
//// [t2.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.y = _t1.x;
|
||||
exports.x = _t1.y;
|
||||
//// [t3.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.y = _t1.x;
|
||||
exports.x = _t1.y;
|
26
tests/baselines/reference/exportsAndImports2.types
Normal file
26
tests/baselines/reference/exportsAndImports2.types
Normal file
|
@ -0,0 +1,26 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
export var x = "x";
|
||||
>x : string
|
||||
|
||||
export var y = "y";
|
||||
>y : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { x as y, y as x } from "./t1";
|
||||
>x : string
|
||||
>y : string
|
||||
>y : string
|
||||
>x : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { x, y } from "./t1";
|
||||
>x : string
|
||||
>y : string
|
||||
|
||||
export { x as y, y as x };
|
||||
>x : string
|
||||
>y : string
|
||||
>y : string
|
||||
>x : string
|
||||
|
84
tests/baselines/reference/exportsAndImports3-amd.js
Normal file
84
tests/baselines/reference/exportsAndImports3-amd.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports3-amd.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var v = 1;
|
||||
export function f() { }
|
||||
export class C {
|
||||
}
|
||||
export interface I {
|
||||
}
|
||||
export enum E {
|
||||
A, B, C
|
||||
}
|
||||
export const enum D {
|
||||
A, B, C
|
||||
}
|
||||
export module M {
|
||||
export var x;
|
||||
}
|
||||
export module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
export import a = M.x;
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
|
||||
//// [t2.ts]
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.v = 1;
|
||||
exports.v1 = exports.v;
|
||||
function f() {
|
||||
}
|
||||
exports.f = f;
|
||||
exports.f1 = exports.f;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
exports.C1 = exports.C;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
E[E["C"] = 2] = "C";
|
||||
})(exports.E || (exports.E = {}));
|
||||
var E = exports.E;
|
||||
exports.E1 = exports.E;
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x;
|
||||
})(M = exports.M || (exports.M = {}));
|
||||
exports.M1 = exports.M;
|
||||
exports.a = M.x;
|
||||
exports.a1 = exports.a;
|
||||
});
|
||||
//// [t2.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.v = _t1.v1;
|
||||
exports.f = _t1.f1;
|
||||
exports.C = _t1.C1;
|
||||
exports.E = _t1.E1;
|
||||
exports.M = _t1.M1;
|
||||
exports.a = _t1.a1;
|
||||
});
|
||||
//// [t3.js]
|
||||
define(["require", "exports", "./t1"], function (require, exports, _t1) {
|
||||
exports.v = _t1.v1;
|
||||
exports.f = _t1.f1;
|
||||
exports.C = _t1.C1;
|
||||
exports.E = _t1.E1;
|
||||
exports.M = _t1.M1;
|
||||
exports.a = _t1.a1;
|
||||
});
|
131
tests/baselines/reference/exportsAndImports3-amd.types
Normal file
131
tests/baselines/reference/exportsAndImports3-amd.types
Normal file
|
@ -0,0 +1,131 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
export var v = 1;
|
||||
>v : number
|
||||
|
||||
export function f() { }
|
||||
>f : () => void
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
}
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
export enum E {
|
||||
>E : E
|
||||
|
||||
A, B, C
|
||||
>A : E
|
||||
>B : E
|
||||
>C : E
|
||||
}
|
||||
export const enum D {
|
||||
>D : D
|
||||
|
||||
A, B, C
|
||||
>A : D
|
||||
>B : D
|
||||
>C : D
|
||||
}
|
||||
export module M {
|
||||
>M : typeof M
|
||||
|
||||
export var x;
|
||||
>x : any
|
||||
}
|
||||
export module N {
|
||||
>N : unknown
|
||||
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
>T : number
|
||||
|
||||
export import a = M.x;
|
||||
>a : any
|
||||
>M : typeof M
|
||||
>x : any
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
>v : number
|
||||
>v1 : number
|
||||
>f : () => void
|
||||
>f1 : () => void
|
||||
>C : typeof C
|
||||
>C1 : typeof C
|
||||
>I : unknown
|
||||
>I1 : unknown
|
||||
>E : typeof E
|
||||
>E1 : typeof E
|
||||
>D : typeof D
|
||||
>D1 : typeof D
|
||||
>M : typeof M
|
||||
>M1 : typeof M
|
||||
>N : unknown
|
||||
>N1 : unknown
|
||||
>T : unknown
|
||||
>T1 : unknown
|
||||
>a : any
|
||||
>a1 : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
>v1 : number
|
||||
>v : number
|
||||
>f1 : () => void
|
||||
>f : () => void
|
||||
>C1 : typeof C
|
||||
>C : typeof C
|
||||
>I1 : unknown
|
||||
>I : unknown
|
||||
>E1 : typeof E
|
||||
>E : typeof E
|
||||
>D1 : typeof D
|
||||
>D : typeof D
|
||||
>M1 : typeof M
|
||||
>M : typeof M
|
||||
>N1 : unknown
|
||||
>N : unknown
|
||||
>T1 : unknown
|
||||
>T : unknown
|
||||
>a1 : any
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
>v1 : number
|
||||
>v : number
|
||||
>f1 : () => void
|
||||
>f : () => void
|
||||
>C1 : typeof C
|
||||
>C : typeof C
|
||||
>I1 : unknown
|
||||
>I : unknown
|
||||
>E1 : typeof E
|
||||
>E : typeof E
|
||||
>D1 : typeof D
|
||||
>D : typeof D
|
||||
>M1 : typeof M
|
||||
>M : typeof M
|
||||
>N1 : unknown
|
||||
>N : unknown
|
||||
>T1 : unknown
|
||||
>T : unknown
|
||||
>a1 : any
|
||||
>a : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
80
tests/baselines/reference/exportsAndImports3.js
Normal file
80
tests/baselines/reference/exportsAndImports3.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports3.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export var v = 1;
|
||||
export function f() { }
|
||||
export class C {
|
||||
}
|
||||
export interface I {
|
||||
}
|
||||
export enum E {
|
||||
A, B, C
|
||||
}
|
||||
export const enum D {
|
||||
A, B, C
|
||||
}
|
||||
export module M {
|
||||
export var x;
|
||||
}
|
||||
export module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
export import a = M.x;
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
|
||||
//// [t2.ts]
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
exports.v = 1;
|
||||
exports.v1 = exports.v;
|
||||
function f() {
|
||||
}
|
||||
exports.f = f;
|
||||
exports.f1 = exports.f;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
exports.C1 = exports.C;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
E[E["C"] = 2] = "C";
|
||||
})(exports.E || (exports.E = {}));
|
||||
var E = exports.E;
|
||||
exports.E1 = exports.E;
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x;
|
||||
})(M = exports.M || (exports.M = {}));
|
||||
exports.M1 = exports.M;
|
||||
exports.a = M.x;
|
||||
exports.a1 = exports.a;
|
||||
//// [t2.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.v = _t1.v1;
|
||||
exports.f = _t1.f1;
|
||||
exports.C = _t1.C1;
|
||||
exports.E = _t1.E1;
|
||||
exports.M = _t1.M1;
|
||||
exports.a = _t1.a1;
|
||||
//// [t3.js]
|
||||
var _t1 = require("./t1");
|
||||
exports.v = _t1.v1;
|
||||
exports.f = _t1.f1;
|
||||
exports.C = _t1.C1;
|
||||
exports.E = _t1.E1;
|
||||
exports.M = _t1.M1;
|
||||
exports.a = _t1.a1;
|
131
tests/baselines/reference/exportsAndImports3.types
Normal file
131
tests/baselines/reference/exportsAndImports3.types
Normal file
|
@ -0,0 +1,131 @@
|
|||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
export var v = 1;
|
||||
>v : number
|
||||
|
||||
export function f() { }
|
||||
>f : () => void
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
}
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
export enum E {
|
||||
>E : E
|
||||
|
||||
A, B, C
|
||||
>A : E
|
||||
>B : E
|
||||
>C : E
|
||||
}
|
||||
export const enum D {
|
||||
>D : D
|
||||
|
||||
A, B, C
|
||||
>A : D
|
||||
>B : D
|
||||
>C : D
|
||||
}
|
||||
export module M {
|
||||
>M : typeof M
|
||||
|
||||
export var x;
|
||||
>x : any
|
||||
}
|
||||
export module N {
|
||||
>N : unknown
|
||||
|
||||
export interface I {
|
||||
>I : I
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
>T : number
|
||||
|
||||
export import a = M.x;
|
||||
>a : any
|
||||
>M : typeof M
|
||||
>x : any
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
>v : number
|
||||
>v1 : number
|
||||
>f : () => void
|
||||
>f1 : () => void
|
||||
>C : typeof C
|
||||
>C1 : typeof C
|
||||
>I : unknown
|
||||
>I1 : unknown
|
||||
>E : typeof E
|
||||
>E1 : typeof E
|
||||
>D : typeof D
|
||||
>D1 : typeof D
|
||||
>M : typeof M
|
||||
>M1 : typeof M
|
||||
>N : unknown
|
||||
>N1 : unknown
|
||||
>T : unknown
|
||||
>T1 : unknown
|
||||
>a : any
|
||||
>a1 : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t2.ts ===
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
>v1 : number
|
||||
>v : number
|
||||
>f1 : () => void
|
||||
>f : () => void
|
||||
>C1 : typeof C
|
||||
>C : typeof C
|
||||
>I1 : unknown
|
||||
>I : unknown
|
||||
>E1 : typeof E
|
||||
>E : typeof E
|
||||
>D1 : typeof D
|
||||
>D : typeof D
|
||||
>M1 : typeof M
|
||||
>M : typeof M
|
||||
>N1 : unknown
|
||||
>N : unknown
|
||||
>T1 : unknown
|
||||
>T : unknown
|
||||
>a1 : any
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
>v1 : number
|
||||
>v : number
|
||||
>f1 : () => void
|
||||
>f : () => void
|
||||
>C1 : typeof C
|
||||
>C : typeof C
|
||||
>I1 : unknown
|
||||
>I : unknown
|
||||
>E1 : typeof E
|
||||
>E : typeof E
|
||||
>D1 : typeof D
|
||||
>D : typeof D
|
||||
>M1 : typeof M
|
||||
>M : typeof M
|
||||
>N1 : unknown
|
||||
>N : unknown
|
||||
>T1 : unknown
|
||||
>T : unknown
|
||||
>a1 : any
|
||||
>a : any
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
>v : number
|
||||
>f : () => void
|
||||
>C : typeof C
|
||||
>I : unknown
|
||||
>E : typeof E
|
||||
>D : typeof D
|
||||
>M : typeof M
|
||||
>N : unknown
|
||||
>T : unknown
|
||||
>a : any
|
||||
|
64
tests/baselines/reference/exportsAndImports4-amd.js
Normal file
64
tests/baselines/reference/exportsAndImports4-amd.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports4-amd.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export default "hello";
|
||||
|
||||
//// [t2.ts]
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
import "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.default = "hello";
|
||||
});
|
||||
//// [t3.js]
|
||||
define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, _t1, c, _t1_2, e2, _t1_4) {
|
||||
exports.a = a;
|
||||
a.default;
|
||||
exports.b = _t1.default;
|
||||
_t1.default;
|
||||
exports.c = c;
|
||||
c.default;
|
||||
exports.d = _t1_2.default;
|
||||
_t1_2.default;
|
||||
exports.e1 = _t1_3.default;
|
||||
exports.e2 = e2;
|
||||
_t1_3.default;
|
||||
e2.default;
|
||||
exports.f1 = _t1_4.default;
|
||||
exports.f2 = _t1_4.default;
|
||||
_t1_4.default;
|
||||
_t1_4.default;
|
||||
});
|
68
tests/baselines/reference/exportsAndImports4-amd.types
Normal file
68
tests/baselines/reference/exportsAndImports4-amd.types
Normal file
|
@ -0,0 +1,68 @@
|
|||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import a = require("./t1");
|
||||
>a : typeof a
|
||||
|
||||
a.default;
|
||||
>a.default : string
|
||||
>a : typeof a
|
||||
>default : string
|
||||
|
||||
import b from "./t1";
|
||||
>b : string
|
||||
|
||||
b;
|
||||
>b : string
|
||||
|
||||
import * as c from "./t1";
|
||||
>c : typeof a
|
||||
|
||||
c.default;
|
||||
>c.default : string
|
||||
>c : typeof a
|
||||
>default : string
|
||||
|
||||
import { default as d } from "./t1";
|
||||
>default : string
|
||||
>d : string
|
||||
|
||||
d;
|
||||
>d : string
|
||||
|
||||
import e1, * as e2 from "./t1";
|
||||
>e1 : string
|
||||
>e2 : typeof a
|
||||
|
||||
e1;
|
||||
>e1 : string
|
||||
|
||||
e2.default;
|
||||
>e2.default : string
|
||||
>e2 : typeof a
|
||||
>default : string
|
||||
|
||||
import f1, { default as f2 } from "./t1";
|
||||
>f1 : string
|
||||
>default : string
|
||||
>f2 : string
|
||||
|
||||
f1;
|
||||
>f1 : string
|
||||
|
||||
f2;
|
||||
>f2 : string
|
||||
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
||||
>a : typeof a
|
||||
>b : string
|
||||
>c : typeof a
|
||||
>d : string
|
||||
>e1 : string
|
||||
>e2 : typeof a
|
||||
>f1 : string
|
||||
>f2 : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
No type information for this code.export default "hello";
|
||||
No type information for this code.
|
||||
No type information for this code.
|
66
tests/baselines/reference/exportsAndImports4.js
Normal file
66
tests/baselines/reference/exportsAndImports4.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
//// [tests/cases/conformance/es6/modules/exportsAndImports4.ts] ////
|
||||
|
||||
//// [t1.ts]
|
||||
|
||||
export default "hello";
|
||||
|
||||
//// [t2.ts]
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
import "./t1";
|
||||
|
||||
//// [t3.ts]
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
||||
|
||||
|
||||
//// [t1.js]
|
||||
exports.default = "hello";
|
||||
//// [t3.js]
|
||||
var a = require("./t1");
|
||||
exports.a = a;
|
||||
a.default;
|
||||
var _t1 = require("./t1");
|
||||
exports.b = _t1.default;
|
||||
_t1.default;
|
||||
var c = require("./t1");
|
||||
exports.c = c;
|
||||
c.default;
|
||||
var _t1_2 = require("./t1");
|
||||
exports.d = _t1_2.default;
|
||||
_t1_2.default;
|
||||
var _t1_3 = require("./t1"), e2 = _t1_3;
|
||||
exports.e1 = _t1_3.default;
|
||||
exports.e2 = e2;
|
||||
_t1_3.default;
|
||||
e2.default;
|
||||
var _t1_4 = require("./t1");
|
||||
exports.f1 = _t1_4.default;
|
||||
exports.f2 = _t1_4.default;
|
||||
_t1_4.default;
|
||||
_t1_4.default;
|
68
tests/baselines/reference/exportsAndImports4.types
Normal file
68
tests/baselines/reference/exportsAndImports4.types
Normal file
|
@ -0,0 +1,68 @@
|
|||
=== tests/cases/conformance/es6/modules/t3.ts ===
|
||||
import a = require("./t1");
|
||||
>a : typeof a
|
||||
|
||||
a.default;
|
||||
>a.default : string
|
||||
>a : typeof a
|
||||
>default : string
|
||||
|
||||
import b from "./t1";
|
||||
>b : string
|
||||
|
||||
b;
|
||||
>b : string
|
||||
|
||||
import * as c from "./t1";
|
||||
>c : typeof a
|
||||
|
||||
c.default;
|
||||
>c.default : string
|
||||
>c : typeof a
|
||||
>default : string
|
||||
|
||||
import { default as d } from "./t1";
|
||||
>default : string
|
||||
>d : string
|
||||
|
||||
d;
|
||||
>d : string
|
||||
|
||||
import e1, * as e2 from "./t1";
|
||||
>e1 : string
|
||||
>e2 : typeof a
|
||||
|
||||
e1;
|
||||
>e1 : string
|
||||
|
||||
e2.default;
|
||||
>e2.default : string
|
||||
>e2 : typeof a
|
||||
>default : string
|
||||
|
||||
import f1, { default as f2 } from "./t1";
|
||||
>f1 : string
|
||||
>default : string
|
||||
>f2 : string
|
||||
|
||||
f1;
|
||||
>f1 : string
|
||||
|
||||
f2;
|
||||
>f2 : string
|
||||
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
||||
>a : typeof a
|
||||
>b : string
|
||||
>c : typeof a
|
||||
>d : string
|
||||
>e1 : string
|
||||
>e2 : typeof a
|
||||
>f1 : string
|
||||
>f2 : string
|
||||
|
||||
=== tests/cases/conformance/es6/modules/t1.ts ===
|
||||
|
||||
No type information for this code.export default "hello";
|
||||
No type information for this code.
|
||||
No type information for this code.
|
206
tests/cases/compiler/es6ExportEqualsInterop.ts
Normal file
206
tests/cases/compiler/es6ExportEqualsInterop.ts
Normal file
|
@ -0,0 +1,206 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: modules.d.ts
|
||||
declare module "interface" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable" {
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-variable" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "module" {
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "interface-module" {
|
||||
interface Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "variable-module" {
|
||||
module Foo {
|
||||
interface Bar {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
var Foo: {
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "function" {
|
||||
function foo();
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "function-module" {
|
||||
function foo();
|
||||
module foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
declare module "class" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
declare module "class-module" {
|
||||
class Foo {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
module Foo {
|
||||
export var a: number;
|
||||
export var b: number;
|
||||
}
|
||||
export = Foo;
|
||||
}
|
||||
|
||||
// @filename: main.ts
|
||||
/// <reference path="modules.d.ts"/>
|
||||
|
||||
// import-equals
|
||||
import z1 = require("interface");
|
||||
import z2 = require("variable");
|
||||
import z3 = require("interface-variable");
|
||||
import z4 = require("module");
|
||||
import z5 = require("interface-module");
|
||||
import z6 = require("variable-module");
|
||||
import z7 = require("function");
|
||||
import z8 = require("function-module");
|
||||
import z9 = require("class");
|
||||
import z0 = require("class-module");
|
||||
|
||||
z1.a;
|
||||
z2.a;
|
||||
z3.a;
|
||||
z4.a;
|
||||
z5.a;
|
||||
z6.a;
|
||||
z7.a;
|
||||
z8.a;
|
||||
z9.a;
|
||||
z0.a;
|
||||
|
||||
// default import
|
||||
import x1 from "interface";
|
||||
import x2 from "variable";
|
||||
import x3 from "interface-variable";
|
||||
import x4 from "module";
|
||||
import x5 from "interface-module";
|
||||
import x6 from "variable-module";
|
||||
import x7 from "function";
|
||||
import x8 from "function-module";
|
||||
import x9 from "class";
|
||||
import x0 from "class-module";
|
||||
|
||||
// namespace import
|
||||
import * as y1 from "interface";
|
||||
import * as y2 from "variable";
|
||||
import * as y3 from "interface-variable";
|
||||
import * as y4 from "module";
|
||||
import * as y5 from "interface-module";
|
||||
import * as y6 from "variable-module";
|
||||
import * as y7 from "function";
|
||||
import * as y8 from "function-module";
|
||||
import * as y9 from "class";
|
||||
import * as y0 from "class-module";
|
||||
|
||||
y1.a;
|
||||
y2.a;
|
||||
y3.a;
|
||||
y4.a;
|
||||
y5.a;
|
||||
y6.a;
|
||||
y7.a;
|
||||
y8.a;
|
||||
y9.a;
|
||||
y0.a;
|
||||
|
||||
// named import
|
||||
import { a as a1 } from "interface";
|
||||
import { a as a2 } from "variable";
|
||||
import { a as a3 } from "interface-variable";
|
||||
import { a as a4 } from "module";
|
||||
import { a as a5 } from "interface-module";
|
||||
import { a as a6 } from "variable-module";
|
||||
import { a as a7 } from "function";
|
||||
import { a as a8 } from "function-module";
|
||||
import { a as a9 } from "class";
|
||||
import { a as a0 } from "class-module";
|
||||
|
||||
a1;
|
||||
a2;
|
||||
a3;
|
||||
a4;
|
||||
a5;
|
||||
a6;
|
||||
a7;
|
||||
a8;
|
||||
a9;
|
||||
a0;
|
||||
|
||||
// named export
|
||||
export { a as a1 } from "interface";
|
||||
export { a as a2 } from "variable";
|
||||
export { a as a3 } from "interface-variable";
|
||||
export { a as a4 } from "module";
|
||||
export { a as a5 } from "interface-module";
|
||||
export { a as a6 } from "variable-module";
|
||||
export { a as a7 } from "function";
|
||||
export { a as a8 } from "function-module";
|
||||
export { a as a9 } from "class";
|
||||
export { a as a0 } from "class-module";
|
||||
|
||||
// export-star
|
||||
export * from "interface";
|
||||
export * from "variable";
|
||||
export * from "interface-variable";
|
||||
export * from "module";
|
||||
export * from "interface-module";
|
||||
export * from "variable-module";
|
||||
export * from "function";
|
||||
export * from "function-module";
|
||||
export * from "class";
|
||||
export * from "class-module";
|
28
tests/cases/conformance/es6/modules/exportStar-amd.ts
Normal file
28
tests/cases/conformance/es6/modules/exportStar-amd.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// @module: amd
|
||||
|
||||
// @filename: t1.ts
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
// @filename: t2.ts
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
// @filename: t3.ts
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
// @filename: t4.ts
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
// @filename: main.ts
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
28
tests/cases/conformance/es6/modules/exportStar.ts
Normal file
28
tests/cases/conformance/es6/modules/exportStar.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export var x = 1;
|
||||
export var y = 2;
|
||||
|
||||
// @filename: t2.ts
|
||||
export default "hello";
|
||||
export function foo() { }
|
||||
|
||||
// @filename: t3.ts
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
// @filename: t4.ts
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
|
||||
// @filename: main.ts
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
hello;
|
||||
x;
|
||||
y;
|
||||
z;
|
||||
foo;
|
|
@ -0,0 +1,33 @@
|
|||
// @module: amd
|
||||
|
||||
// @filename: t1.ts
|
||||
var v = 1;
|
||||
function f() { }
|
||||
class C {
|
||||
}
|
||||
interface I {
|
||||
}
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
const enum D {
|
||||
A, B, C
|
||||
}
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
import a = M.x;
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
33
tests/cases/conformance/es6/modules/exportsAndImports1.ts
Normal file
33
tests/cases/conformance/es6/modules/exportsAndImports1.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
var v = 1;
|
||||
function f() { }
|
||||
class C {
|
||||
}
|
||||
interface I {
|
||||
}
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
const enum D {
|
||||
A, B, C
|
||||
}
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
import a = M.x;
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
|
@ -0,0 +1,12 @@
|
|||
// @module: amd
|
||||
|
||||
// @filename: t1.ts
|
||||
export var x = "x";
|
||||
export var y = "y";
|
||||
|
||||
// @filename: t2.ts
|
||||
export { x as y, y as x } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { x, y } from "./t1";
|
||||
export { x as y, y as x };
|
12
tests/cases/conformance/es6/modules/exportsAndImports2.ts
Normal file
12
tests/cases/conformance/es6/modules/exportsAndImports2.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export var x = "x";
|
||||
export var y = "y";
|
||||
|
||||
// @filename: t2.ts
|
||||
export { x as y, y as x } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { x, y } from "./t1";
|
||||
export { x as y, y as x };
|
|
@ -0,0 +1,33 @@
|
|||
// @module: amd
|
||||
|
||||
// @filename: t1.ts
|
||||
export var v = 1;
|
||||
export function f() { }
|
||||
export class C {
|
||||
}
|
||||
export interface I {
|
||||
}
|
||||
export enum E {
|
||||
A, B, C
|
||||
}
|
||||
export const enum D {
|
||||
A, B, C
|
||||
}
|
||||
export module M {
|
||||
export var x;
|
||||
}
|
||||
export module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
export import a = M.x;
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
33
tests/cases/conformance/es6/modules/exportsAndImports3.ts
Normal file
33
tests/cases/conformance/es6/modules/exportsAndImports3.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export var v = 1;
|
||||
export function f() { }
|
||||
export class C {
|
||||
}
|
||||
export interface I {
|
||||
}
|
||||
export enum E {
|
||||
A, B, C
|
||||
}
|
||||
export const enum D {
|
||||
A, B, C
|
||||
}
|
||||
export module M {
|
||||
export var x;
|
||||
}
|
||||
export module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
export import a = M.x;
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
|
@ -0,0 +1,38 @@
|
|||
// @module: amd
|
||||
|
||||
// @filename: t1.ts
|
||||
export default "hello";
|
||||
|
||||
// @filename: t2.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
import "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
38
tests/cases/conformance/es6/modules/exportsAndImports4.ts
Normal file
38
tests/cases/conformance/es6/modules/exportsAndImports4.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export default "hello";
|
||||
|
||||
// @filename: t2.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
import "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
Loading…
Reference in a new issue