mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
allow augmentation for entities exported via 'export='
This commit is contained in:
@@ -395,10 +395,17 @@ namespace ts {
|
||||
if (!mainModule) {
|
||||
return;
|
||||
}
|
||||
// if module symbol has already been merged - it is safe to use it.
|
||||
// otherwise clone it
|
||||
mainModule = mainModule.flags & SymbolFlags.Merged ? mainModule : cloneSymbol(mainModule);
|
||||
mergeSymbol(mainModule, moduleAugmentation.symbol);
|
||||
// obtain item referenced by 'export='
|
||||
mainModule = resolveExternalModuleSymbol(mainModule);
|
||||
if (mainModule.flags & SymbolFlags.Namespace) {
|
||||
// if module symbol has already been merged - it is safe to use it.
|
||||
// otherwise clone it
|
||||
mainModule = mainModule.flags & SymbolFlags.Merged ? mainModule : cloneSymbol(mainModule);
|
||||
mergeSymbol(mainModule, moduleAugmentation.symbol);
|
||||
}
|
||||
else {
|
||||
error(moduleName, Diagnostics.Cannot_augment_module_0_that_resolves_to_a_non_module_entity, moduleName.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,7 +898,7 @@ namespace ts {
|
||||
error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
|
||||
}
|
||||
else if (!exportDefaultSymbol && allowSyntheticDefaultImports) {
|
||||
return resolveSymbol(moduleSymbol.exports["export="]) || resolveSymbol(moduleSymbol);
|
||||
return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol);
|
||||
}
|
||||
return exportDefaultSymbol;
|
||||
}
|
||||
@@ -1182,7 +1189,7 @@ namespace ts {
|
||||
// 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;
|
||||
return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol;
|
||||
}
|
||||
|
||||
// An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export ='
|
||||
@@ -1197,8 +1204,8 @@ namespace ts {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
function getExportAssignmentSymbol(moduleSymbol: Symbol): Symbol {
|
||||
return moduleSymbol.exports["export="];
|
||||
function hasExportAssignmentSymbol(moduleSymbol: Symbol): boolean {
|
||||
return moduleSymbol.exports["export="] !== undefined;
|
||||
}
|
||||
|
||||
function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] {
|
||||
@@ -14845,7 +14852,7 @@ namespace ts {
|
||||
else {
|
||||
// export * from "foo"
|
||||
const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
|
||||
if (moduleSymbol && moduleSymbol.exports["export="]) {
|
||||
if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
|
||||
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
|
||||
}
|
||||
}
|
||||
@@ -15683,7 +15690,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
const hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined;
|
||||
const hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
|
||||
// if module has export assignment then 'resolveExternalModuleSymbol' will return resolved symbol for export assignment
|
||||
// otherwise it will return moduleSymbol itself
|
||||
moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
|
||||
@@ -16042,7 +16049,7 @@ namespace ts {
|
||||
if (!isExternalOrCommonJsModule(file)) {
|
||||
mergeSymbolTable(globals, file.locals);
|
||||
}
|
||||
if (file.moduleAugmentations) {
|
||||
if (file.moduleAugmentations.length) {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1819,6 +1819,10 @@
|
||||
"category": "Error",
|
||||
"code": 2670
|
||||
},
|
||||
"Cannot augment module '{0}' that resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
"code": 2671
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
||||
26
tests/baselines/reference/augmentExportEquals1.errors.txt
Normal file
26
tests/baselines/reference/augmentExportEquals1.errors.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
tests/cases/compiler/file2.ts(6,16): error TS2671: Cannot augment module './file1' that resolves to a non-module entity.
|
||||
tests/cases/compiler/file3.ts(3,8): error TS2503: Cannot find namespace 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file3.ts (1 errors) ====
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
~
|
||||
!!! error TS2503: Cannot find namespace 'x'.
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
var x = 1;
|
||||
export = x;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
|
||||
import x = require("./file1");
|
||||
|
||||
// augmentation for './file1'
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
~~~~~~~~~
|
||||
!!! error TS2671: Cannot augment module './file1' that resolves to a non-module entity.
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
36
tests/baselines/reference/augmentExportEquals1.js
Normal file
36
tests/baselines/reference/augmentExportEquals1.js
Normal file
@@ -0,0 +1,36 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
var x = 1;
|
||||
export = x;
|
||||
|
||||
//// [file2.ts]
|
||||
|
||||
import x = require("./file1");
|
||||
|
||||
// augmentation for './file1'
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var x = 1;
|
||||
return x;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports) {
|
||||
"use strict";
|
||||
var a; // should not work
|
||||
});
|
||||
29
tests/baselines/reference/augmentExportEquals1_1.errors.txt
Normal file
29
tests/baselines/reference/augmentExportEquals1_1.errors.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/file2.ts(6,16): error TS2671: Cannot augment module 'file1' that resolves to a non-module entity.
|
||||
tests/cases/compiler/file3.ts(3,8): error TS2503: Cannot find namespace 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file3.ts (1 errors) ====
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
~
|
||||
!!! error TS2503: Cannot find namespace 'x'.
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
|
||||
declare module "file1" {
|
||||
var x: number;
|
||||
export = x;
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// augmentation for 'file1'
|
||||
// should error since 'file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
~~~~~~~
|
||||
!!! error TS2671: Cannot augment module 'file1' that resolves to a non-module entity.
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
33
tests/baselines/reference/augmentExportEquals1_1.js
Normal file
33
tests/baselines/reference/augmentExportEquals1_1.js
Normal file
@@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals1_1.ts] ////
|
||||
|
||||
//// [file1.d.ts]
|
||||
|
||||
declare module "file1" {
|
||||
var x: number;
|
||||
export = x;
|
||||
}
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// augmentation for 'file1'
|
||||
// should error since 'file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "file2"], function (require, exports) {
|
||||
"use strict";
|
||||
var a; // should not work
|
||||
});
|
||||
25
tests/baselines/reference/augmentExportEquals2.errors.txt
Normal file
25
tests/baselines/reference/augmentExportEquals2.errors.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
tests/cases/compiler/file2.ts(4,16): error TS2671: Cannot augment module './file1' that resolves to a non-module entity.
|
||||
tests/cases/compiler/file3.ts(3,8): error TS2503: Cannot find namespace 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file3.ts (1 errors) ====
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
~
|
||||
!!! error TS2503: Cannot find namespace 'x'.
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
|
||||
function foo() {}
|
||||
export = foo;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
import x = require("./file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
~~~~~~~~~
|
||||
!!! error TS2671: Cannot augment module './file1' that resolves to a non-module entity.
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
35
tests/baselines/reference/augmentExportEquals2.js
Normal file
35
tests/baselines/reference/augmentExportEquals2.js
Normal file
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals2.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
function foo() {}
|
||||
export = foo;
|
||||
|
||||
//// [file2.ts]
|
||||
import x = require("./file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
return foo;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports) {
|
||||
"use strict";
|
||||
var a; // should not work
|
||||
});
|
||||
29
tests/baselines/reference/augmentExportEquals2_1.errors.txt
Normal file
29
tests/baselines/reference/augmentExportEquals2_1.errors.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/file2.ts(6,16): error TS2671: Cannot augment module 'file1' that resolves to a non-module entity.
|
||||
tests/cases/compiler/file3.ts(3,8): error TS2503: Cannot find namespace 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file3.ts (1 errors) ====
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
~
|
||||
!!! error TS2503: Cannot find namespace 'x'.
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
export = foo;
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
~~~~~~~
|
||||
!!! error TS2671: Cannot augment module 'file1' that resolves to a non-module entity.
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
33
tests/baselines/reference/augmentExportEquals2_1.js
Normal file
33
tests/baselines/reference/augmentExportEquals2_1.js
Normal file
@@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals2_1.ts] ////
|
||||
|
||||
//// [file1.d.ts]
|
||||
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
export = foo;
|
||||
}
|
||||
|
||||
//// [file2.ts]
|
||||
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "file2"], function (require, exports) {
|
||||
"use strict";
|
||||
var a; // should not work
|
||||
});
|
||||
31
tests/baselines/reference/augmentExportEquals3.errors.txt
Normal file
31
tests/baselines/reference/augmentExportEquals3.errors.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
tests/cases/compiler/file2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(7,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
|
||||
function foo() {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
47
tests/baselines/reference/augmentExportEquals3.js
Normal file
47
tests/baselines/reference/augmentExportEquals3.js
Normal file
@@ -0,0 +1,47 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals3.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
function foo() {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
//// [file2.ts]
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
var foo;
|
||||
(function (foo) {
|
||||
foo.v = 1;
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file1"], function (require, exports, x) {
|
||||
"use strict";
|
||||
x.b = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "./file1", "./file2"], function (require, exports, x) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = x.b;
|
||||
});
|
||||
34
tests/baselines/reference/augmentExportEquals3_1.errors.txt
Normal file
34
tests/baselines/reference/augmentExportEquals3_1.errors.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
tests/cases/compiler/file2.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(8,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
40
tests/baselines/reference/augmentExportEquals3_1.js
Normal file
40
tests/baselines/reference/augmentExportEquals3_1.js
Normal file
@@ -0,0 +1,40 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals3_1.ts] ////
|
||||
|
||||
//// [file1.d.ts]
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "file1"], function (require, exports, x) {
|
||||
"use strict";
|
||||
x.b = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "file1", "file2"], function (require, exports, x) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = x.b;
|
||||
});
|
||||
31
tests/baselines/reference/augmentExportEquals4.errors.txt
Normal file
31
tests/baselines/reference/augmentExportEquals4.errors.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
tests/cases/compiler/file2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(7,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
51
tests/baselines/reference/augmentExportEquals4.js
Normal file
51
tests/baselines/reference/augmentExportEquals4.js
Normal file
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals4.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
//// [file2.ts]
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
return foo;
|
||||
}());
|
||||
var foo;
|
||||
(function (foo) {
|
||||
foo.v = 1;
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file1"], function (require, exports, x) {
|
||||
"use strict";
|
||||
x.b = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "./file1", "./file2"], function (require, exports, x) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = x.b;
|
||||
});
|
||||
35
tests/baselines/reference/augmentExportEquals4_1.errors.txt
Normal file
35
tests/baselines/reference/augmentExportEquals4_1.errors.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
tests/cases/compiler/file2.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(8,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
41
tests/baselines/reference/augmentExportEquals4_1.js
Normal file
41
tests/baselines/reference/augmentExportEquals4_1.js
Normal file
@@ -0,0 +1,41 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals4_1.ts] ////
|
||||
|
||||
//// [file1.d.ts]
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "file1"], function (require, exports, x) {
|
||||
"use strict";
|
||||
x.b = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "file1", "file2"], function (require, exports, x) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = x.b;
|
||||
});
|
||||
94
tests/baselines/reference/augmentExportEquals5.js
Normal file
94
tests/baselines/reference/augmentExportEquals5.js
Normal file
@@ -0,0 +1,94 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals5.ts] ////
|
||||
|
||||
//// [express.d.ts]
|
||||
|
||||
|
||||
declare module Express {
|
||||
export interface Request { }
|
||||
export interface Response { }
|
||||
export interface Application { }
|
||||
}
|
||||
|
||||
declare module "express" {
|
||||
function e(): e.Express;
|
||||
namespace e {
|
||||
interface IRoute {
|
||||
all(...handler: RequestHandler[]): IRoute;
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
(name: string|RegExp, ...handlers: RequestHandler[]): T;
|
||||
}
|
||||
|
||||
interface IRouter<T> extends RequestHandler {
|
||||
route(path: string): IRoute;
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
|
||||
export interface Router extends IRouter<Router> {}
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
|
||||
interface Request extends Express.Request {
|
||||
|
||||
get (name: string): string;
|
||||
}
|
||||
|
||||
interface Response extends Express.Response {
|
||||
charset: string;
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
(err: any, req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
(req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface Handler extends RequestHandler {}
|
||||
|
||||
interface RequestParamHandler {
|
||||
(req: Request, res: Response, next: Function, param: any): any;
|
||||
}
|
||||
|
||||
interface Application extends IRouter<Application>, Express.Application {
|
||||
routes: any;
|
||||
}
|
||||
|
||||
interface Express extends Application {
|
||||
createApplication(): Application;
|
||||
}
|
||||
|
||||
var static: any;
|
||||
}
|
||||
|
||||
export = e;
|
||||
}
|
||||
|
||||
//// [augmentation.ts]
|
||||
/// <reference path="express.d.ts"/>
|
||||
import * as e from "express";
|
||||
declare module "express" {
|
||||
interface Request {
|
||||
id: number;
|
||||
}
|
||||
}
|
||||
|
||||
//// [consumer.ts]
|
||||
import { Request } from "express";
|
||||
import "./augmentation";
|
||||
let x: Request;
|
||||
const y = x.id;
|
||||
|
||||
//// [augmentation.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [consumer.js]
|
||||
define(["require", "exports", "./augmentation"], function (require, exports) {
|
||||
"use strict";
|
||||
var x;
|
||||
var y = x.id;
|
||||
});
|
||||
194
tests/baselines/reference/augmentExportEquals5.symbols
Normal file
194
tests/baselines/reference/augmentExportEquals5.symbols
Normal file
@@ -0,0 +1,194 @@
|
||||
=== tests/cases/compiler/express.d.ts ===
|
||||
|
||||
|
||||
declare module Express {
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 0, 0))
|
||||
|
||||
export interface Request { }
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 2, 24))
|
||||
|
||||
export interface Response { }
|
||||
>Response : Symbol(Response, Decl(express.d.ts, 3, 32))
|
||||
|
||||
export interface Application { }
|
||||
>Application : Symbol(Application, Decl(express.d.ts, 4, 33))
|
||||
}
|
||||
|
||||
declare module "express" {
|
||||
function e(): e.Express;
|
||||
>e : Symbol(, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29))
|
||||
>e : Symbol(e, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28))
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 54, 9))
|
||||
|
||||
namespace e {
|
||||
>e : Symbol(, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29))
|
||||
|
||||
interface IRoute {
|
||||
>IRoute : Symbol(IRoute, Decl(express.d.ts, 10, 17))
|
||||
|
||||
all(...handler: RequestHandler[]): IRoute;
|
||||
>all : Symbol(all, Decl(express.d.ts, 11, 26))
|
||||
>handler : Symbol(handler, Decl(express.d.ts, 12, 16))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 40, 9))
|
||||
>IRoute : Symbol(IRoute, Decl(express.d.ts, 10, 17))
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
>IRouterMatcher : Symbol(IRouterMatcher, Decl(express.d.ts, 13, 9))
|
||||
>T : Symbol(T, Decl(express.d.ts, 15, 33))
|
||||
|
||||
(name: string|RegExp, ...handlers: RequestHandler[]): T;
|
||||
>name : Symbol(name, Decl(express.d.ts, 16, 13))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>handlers : Symbol(handlers, Decl(express.d.ts, 16, 33))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 40, 9))
|
||||
>T : Symbol(T, Decl(express.d.ts, 15, 33))
|
||||
}
|
||||
|
||||
interface IRouter<T> extends RequestHandler {
|
||||
>IRouter : Symbol(IRouter, Decl(express.d.ts, 17, 9))
|
||||
>T : Symbol(T, Decl(express.d.ts, 19, 26))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 40, 9))
|
||||
|
||||
route(path: string): IRoute;
|
||||
>route : Symbol(route, Decl(express.d.ts, 19, 53))
|
||||
>path : Symbol(path, Decl(express.d.ts, 20, 18))
|
||||
>IRoute : Symbol(IRoute, Decl(express.d.ts, 10, 17))
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
>Router : Symbol(Router, Decl(express.d.ts, 21, 9), Decl(express.d.ts, 23, 54))
|
||||
>options : Symbol(options, Decl(express.d.ts, 23, 31))
|
||||
>Router : Symbol(Router, Decl(express.d.ts, 21, 9), Decl(express.d.ts, 23, 54))
|
||||
|
||||
export interface Router extends IRouter<Router> {}
|
||||
>Router : Symbol(Router, Decl(express.d.ts, 21, 9), Decl(express.d.ts, 23, 54))
|
||||
>IRouter : Symbol(IRouter, Decl(express.d.ts, 17, 9))
|
||||
>Router : Symbol(Router, Decl(express.d.ts, 21, 9), Decl(express.d.ts, 23, 54))
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
>Errback : Symbol(Errback, Decl(express.d.ts, 25, 58))
|
||||
>err : Symbol(err, Decl(express.d.ts, 27, 29))
|
||||
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
interface Request extends Express.Request {
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 27, 49), Decl(augmentation.ts, 2, 26))
|
||||
>Express.Request : Symbol(Express.Request, Decl(express.d.ts, 2, 24))
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 0, 0))
|
||||
>Request : Symbol(Express.Request, Decl(express.d.ts, 2, 24))
|
||||
|
||||
get (name: string): string;
|
||||
>get : Symbol(get, Decl(express.d.ts, 29, 51))
|
||||
>name : Symbol(name, Decl(express.d.ts, 31, 17))
|
||||
}
|
||||
|
||||
interface Response extends Express.Response {
|
||||
>Response : Symbol(Response, Decl(express.d.ts, 32, 9))
|
||||
>Express.Response : Symbol(Express.Response, Decl(express.d.ts, 3, 32))
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 0, 0))
|
||||
>Response : Symbol(Express.Response, Decl(express.d.ts, 3, 32))
|
||||
|
||||
charset: string;
|
||||
>charset : Symbol(charset, Decl(express.d.ts, 34, 53))
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
>ErrorRequestHandler : Symbol(ErrorRequestHandler, Decl(express.d.ts, 36, 9))
|
||||
|
||||
(err: any, req: Request, res: Response, next: Function): any;
|
||||
>err : Symbol(err, Decl(express.d.ts, 39, 13))
|
||||
>req : Symbol(req, Decl(express.d.ts, 39, 22))
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 27, 49), Decl(augmentation.ts, 2, 26))
|
||||
>res : Symbol(res, Decl(express.d.ts, 39, 36))
|
||||
>Response : Symbol(Response, Decl(express.d.ts, 32, 9))
|
||||
>next : Symbol(next, Decl(express.d.ts, 39, 51))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 40, 9))
|
||||
|
||||
(req: Request, res: Response, next: Function): any;
|
||||
>req : Symbol(req, Decl(express.d.ts, 43, 13))
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 27, 49), Decl(augmentation.ts, 2, 26))
|
||||
>res : Symbol(res, Decl(express.d.ts, 43, 26))
|
||||
>Response : Symbol(Response, Decl(express.d.ts, 32, 9))
|
||||
>next : Symbol(next, Decl(express.d.ts, 43, 41))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
}
|
||||
|
||||
interface Handler extends RequestHandler {}
|
||||
>Handler : Symbol(Handler, Decl(express.d.ts, 44, 9))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 40, 9))
|
||||
|
||||
interface RequestParamHandler {
|
||||
>RequestParamHandler : Symbol(RequestParamHandler, Decl(express.d.ts, 46, 51))
|
||||
|
||||
(req: Request, res: Response, next: Function, param: any): any;
|
||||
>req : Symbol(req, Decl(express.d.ts, 49, 13))
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 27, 49), Decl(augmentation.ts, 2, 26))
|
||||
>res : Symbol(res, Decl(express.d.ts, 49, 26))
|
||||
>Response : Symbol(Response, Decl(express.d.ts, 32, 9))
|
||||
>next : Symbol(next, Decl(express.d.ts, 49, 41))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>param : Symbol(param, Decl(express.d.ts, 49, 57))
|
||||
}
|
||||
|
||||
interface Application extends IRouter<Application>, Express.Application {
|
||||
>Application : Symbol(Application, Decl(express.d.ts, 50, 9))
|
||||
>IRouter : Symbol(IRouter, Decl(express.d.ts, 17, 9))
|
||||
>Application : Symbol(Application, Decl(express.d.ts, 50, 9))
|
||||
>Express.Application : Symbol(Express.Application, Decl(express.d.ts, 4, 33))
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 0, 0))
|
||||
>Application : Symbol(Express.Application, Decl(express.d.ts, 4, 33))
|
||||
|
||||
routes: any;
|
||||
>routes : Symbol(routes, Decl(express.d.ts, 52, 81))
|
||||
}
|
||||
|
||||
interface Express extends Application {
|
||||
>Express : Symbol(Express, Decl(express.d.ts, 54, 9))
|
||||
>Application : Symbol(Application, Decl(express.d.ts, 50, 9))
|
||||
|
||||
createApplication(): Application;
|
||||
>createApplication : Symbol(createApplication, Decl(express.d.ts, 56, 47))
|
||||
>Application : Symbol(Application, Decl(express.d.ts, 50, 9))
|
||||
}
|
||||
|
||||
var static: any;
|
||||
>static : Symbol(static, Decl(express.d.ts, 60, 11))
|
||||
}
|
||||
|
||||
export = e;
|
||||
>e : Symbol(e, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/augmentation.ts ===
|
||||
/// <reference path="express.d.ts"/>
|
||||
import * as e from "express";
|
||||
>e : Symbol(e, Decl(augmentation.ts, 1, 6))
|
||||
|
||||
declare module "express" {
|
||||
interface Request {
|
||||
>Request : Symbol(Request, Decl(express.d.ts, 27, 49), Decl(augmentation.ts, 2, 26))
|
||||
|
||||
id: number;
|
||||
>id : Symbol(id, Decl(augmentation.ts, 3, 23))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/consumer.ts ===
|
||||
import { Request } from "express";
|
||||
>Request : Symbol(Request, Decl(consumer.ts, 0, 8))
|
||||
|
||||
import "./augmentation";
|
||||
let x: Request;
|
||||
>x : Symbol(x, Decl(consumer.ts, 2, 3))
|
||||
>Request : Symbol(Request, Decl(consumer.ts, 0, 8))
|
||||
|
||||
const y = x.id;
|
||||
>y : Symbol(y, Decl(consumer.ts, 3, 5))
|
||||
>x.id : Symbol(Request.id, Decl(augmentation.ts, 3, 23))
|
||||
>x : Symbol(x, Decl(consumer.ts, 2, 3))
|
||||
>id : Symbol(Request.id, Decl(augmentation.ts, 3, 23))
|
||||
|
||||
194
tests/baselines/reference/augmentExportEquals5.types
Normal file
194
tests/baselines/reference/augmentExportEquals5.types
Normal file
@@ -0,0 +1,194 @@
|
||||
=== tests/cases/compiler/express.d.ts ===
|
||||
|
||||
|
||||
declare module Express {
|
||||
>Express : any
|
||||
|
||||
export interface Request { }
|
||||
>Request : Request
|
||||
|
||||
export interface Response { }
|
||||
>Response : Response
|
||||
|
||||
export interface Application { }
|
||||
>Application : Application
|
||||
}
|
||||
|
||||
declare module "express" {
|
||||
function e(): e.Express;
|
||||
>e : typeof
|
||||
>e : any
|
||||
>Express : Express
|
||||
|
||||
namespace e {
|
||||
>e : typeof
|
||||
|
||||
interface IRoute {
|
||||
>IRoute : IRoute
|
||||
|
||||
all(...handler: RequestHandler[]): IRoute;
|
||||
>all : (...handler: RequestHandler[]) => IRoute
|
||||
>handler : RequestHandler[]
|
||||
>RequestHandler : RequestHandler
|
||||
>IRoute : IRoute
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
>IRouterMatcher : IRouterMatcher<T>
|
||||
>T : T
|
||||
|
||||
(name: string|RegExp, ...handlers: RequestHandler[]): T;
|
||||
>name : string | RegExp
|
||||
>RegExp : RegExp
|
||||
>handlers : RequestHandler[]
|
||||
>RequestHandler : RequestHandler
|
||||
>T : T
|
||||
}
|
||||
|
||||
interface IRouter<T> extends RequestHandler {
|
||||
>IRouter : IRouter<T>
|
||||
>T : T
|
||||
>RequestHandler : RequestHandler
|
||||
|
||||
route(path: string): IRoute;
|
||||
>route : (path: string) => IRoute
|
||||
>path : string
|
||||
>IRoute : IRoute
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
>Router : (options?: any) => Router
|
||||
>options : any
|
||||
>Router : Router
|
||||
|
||||
export interface Router extends IRouter<Router> {}
|
||||
>Router : Router
|
||||
>IRouter : IRouter<T>
|
||||
>Router : Router
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
>Errback : Errback
|
||||
>err : Error
|
||||
>Error : Error
|
||||
|
||||
interface Request extends Express.Request {
|
||||
>Request : Request
|
||||
>Express.Request : any
|
||||
>Express : any
|
||||
>Request : Express.Request
|
||||
|
||||
get (name: string): string;
|
||||
>get : (name: string) => string
|
||||
>name : string
|
||||
}
|
||||
|
||||
interface Response extends Express.Response {
|
||||
>Response : Response
|
||||
>Express.Response : any
|
||||
>Express : any
|
||||
>Response : Express.Response
|
||||
|
||||
charset: string;
|
||||
>charset : string
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
>ErrorRequestHandler : ErrorRequestHandler
|
||||
|
||||
(err: any, req: Request, res: Response, next: Function): any;
|
||||
>err : any
|
||||
>req : Request
|
||||
>Request : Request
|
||||
>res : Response
|
||||
>Response : Response
|
||||
>next : Function
|
||||
>Function : Function
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
>RequestHandler : RequestHandler
|
||||
|
||||
(req: Request, res: Response, next: Function): any;
|
||||
>req : Request
|
||||
>Request : Request
|
||||
>res : Response
|
||||
>Response : Response
|
||||
>next : Function
|
||||
>Function : Function
|
||||
}
|
||||
|
||||
interface Handler extends RequestHandler {}
|
||||
>Handler : Handler
|
||||
>RequestHandler : RequestHandler
|
||||
|
||||
interface RequestParamHandler {
|
||||
>RequestParamHandler : RequestParamHandler
|
||||
|
||||
(req: Request, res: Response, next: Function, param: any): any;
|
||||
>req : Request
|
||||
>Request : Request
|
||||
>res : Response
|
||||
>Response : Response
|
||||
>next : Function
|
||||
>Function : Function
|
||||
>param : any
|
||||
}
|
||||
|
||||
interface Application extends IRouter<Application>, Express.Application {
|
||||
>Application : Application
|
||||
>IRouter : IRouter<T>
|
||||
>Application : Application
|
||||
>Express.Application : any
|
||||
>Express : any
|
||||
>Application : Express.Application
|
||||
|
||||
routes: any;
|
||||
>routes : any
|
||||
}
|
||||
|
||||
interface Express extends Application {
|
||||
>Express : Express
|
||||
>Application : Application
|
||||
|
||||
createApplication(): Application;
|
||||
>createApplication : () => Application
|
||||
>Application : Application
|
||||
}
|
||||
|
||||
var static: any;
|
||||
>static : any
|
||||
}
|
||||
|
||||
export = e;
|
||||
>e : typeof e
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/augmentation.ts ===
|
||||
/// <reference path="express.d.ts"/>
|
||||
import * as e from "express";
|
||||
>e : typeof e
|
||||
|
||||
declare module "express" {
|
||||
interface Request {
|
||||
>Request : Request
|
||||
|
||||
id: number;
|
||||
>id : number
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/consumer.ts ===
|
||||
import { Request } from "express";
|
||||
>Request : any
|
||||
|
||||
import "./augmentation";
|
||||
let x: Request;
|
||||
>x : Request
|
||||
>Request : Request
|
||||
|
||||
const y = x.id;
|
||||
>y : number
|
||||
>x.id : number
|
||||
>x : Request
|
||||
>id : number
|
||||
|
||||
64
tests/baselines/reference/augmentExportEquals6.js
Normal file
64
tests/baselines/reference/augmentExportEquals6.js
Normal file
@@ -0,0 +1,64 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals6.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export class A {}
|
||||
export namespace B { export let a; }
|
||||
}
|
||||
export = foo;
|
||||
|
||||
//// [file2.ts]
|
||||
import x = require("./file1");
|
||||
x.B.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a: number }
|
||||
namespace B {
|
||||
export let b: number;
|
||||
}
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
let c = x.B.b;
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
return foo;
|
||||
}());
|
||||
var foo;
|
||||
(function (foo) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
foo.A = A;
|
||||
var B;
|
||||
(function (B) {
|
||||
})(B = foo.B || (foo.B = {}));
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file1"], function (require, exports, x) {
|
||||
"use strict";
|
||||
x.B.b = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "./file1", "./file2"], function (require, exports, x) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = a.a;
|
||||
var c = x.B.b;
|
||||
});
|
||||
67
tests/baselines/reference/augmentExportEquals6.symbols
Normal file
67
tests/baselines/reference/augmentExportEquals6.symbols
Normal file
@@ -0,0 +1,67 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10))
|
||||
|
||||
export class A {}
|
||||
>A : Symbol(A, Decl(file1.ts, 2, 15), Decl(file2.ts, 4, 26))
|
||||
|
||||
export namespace B { export let a; }
|
||||
>B : Symbol(B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
>a : Symbol(a, Decl(file1.ts, 4, 35))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12))
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
x.B.b = 1;
|
||||
>x.B.b : Symbol(x.B.b, Decl(file2.ts, 7, 18))
|
||||
>x.B : Symbol(x.B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
>B : Symbol(x.B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
>b : Symbol(x.B.b, Decl(file2.ts, 7, 18))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a: number }
|
||||
>A : Symbol(A, Decl(file1.ts, 2, 15), Decl(file2.ts, 4, 26))
|
||||
>a : Symbol(a, Decl(file2.ts, 5, 17))
|
||||
|
||||
namespace B {
|
||||
>B : Symbol(B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
|
||||
export let b: number;
|
||||
>b : Symbol(b, Decl(file2.ts, 7, 18))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file1.ts, 2, 15), Decl(file2.ts, 4, 26))
|
||||
|
||||
let b = a.a;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>a.a : Symbol(x.A.a, Decl(file2.ts, 5, 17))
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>a : Symbol(x.A.a, Decl(file2.ts, 5, 17))
|
||||
|
||||
let c = x.B.b;
|
||||
>c : Symbol(c, Decl(file3.ts, 4, 3))
|
||||
>x.B.b : Symbol(x.B.b, Decl(file2.ts, 7, 18))
|
||||
>x.B : Symbol(x.B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>B : Symbol(x.B, Decl(file1.ts, 3, 21), Decl(file2.ts, 5, 29))
|
||||
>b : Symbol(x.B.b, Decl(file2.ts, 7, 18))
|
||||
|
||||
69
tests/baselines/reference/augmentExportEquals6.types
Normal file
69
tests/baselines/reference/augmentExportEquals6.types
Normal file
@@ -0,0 +1,69 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo :
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
export class A {}
|
||||
>A : A
|
||||
|
||||
export namespace B { export let a; }
|
||||
>B : typeof B
|
||||
>a : any
|
||||
}
|
||||
export = foo;
|
||||
>foo : foo
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : typeof x
|
||||
|
||||
x.B.b = 1;
|
||||
>x.B.b = 1 : number
|
||||
>x.B.b : number
|
||||
>x.B : typeof x.B
|
||||
>x : typeof x
|
||||
>B : typeof x.B
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a: number }
|
||||
>A : A
|
||||
>a : number
|
||||
|
||||
namespace B {
|
||||
>B : typeof B
|
||||
|
||||
export let b: number;
|
||||
>b : number
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : typeof x
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = a.a;
|
||||
>b : number
|
||||
>a.a : number
|
||||
>a : x.A
|
||||
>a : number
|
||||
|
||||
let c = x.B.b;
|
||||
>c : number
|
||||
>x.B.b : number
|
||||
>x.B : typeof x.B
|
||||
>x : typeof x
|
||||
>B : typeof x.B
|
||||
>b : number
|
||||
|
||||
38
tests/baselines/reference/augmentExportEquals6_1.js
Normal file
38
tests/baselines/reference/augmentExportEquals6_1.js
Normal file
@@ -0,0 +1,38 @@
|
||||
//// [tests/cases/compiler/augmentExportEquals6_1.ts] ////
|
||||
|
||||
//// [file1.d.ts]
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
class A {}
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a: number }
|
||||
}
|
||||
|
||||
//// [file3.ts]
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "file2"], function (require, exports) {
|
||||
"use strict";
|
||||
var a;
|
||||
var b = a.a;
|
||||
});
|
||||
45
tests/baselines/reference/augmentExportEquals6_1.symbols
Normal file
45
tests/baselines/reference/augmentExportEquals6_1.symbols
Normal file
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
>foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28))
|
||||
|
||||
class A {}
|
||||
>A : Symbol(A, Decl(file1.d.ts, 3, 19), Decl(file2.ts, 4, 24))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16))
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a: number }
|
||||
>A : Symbol(A, Decl(file1.d.ts, 3, 19), Decl(file2.ts, 4, 24))
|
||||
>a : Symbol(a, Decl(file2.ts, 5, 17))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file1.d.ts, 3, 19), Decl(file2.ts, 4, 24))
|
||||
|
||||
let b = a.a;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>a.a : Symbol(x.A.a, Decl(file2.ts, 5, 17))
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>a : Symbol(x.A.a, Decl(file2.ts, 5, 17))
|
||||
|
||||
45
tests/baselines/reference/augmentExportEquals6_1.types
Normal file
45
tests/baselines/reference/augmentExportEquals6_1.types
Normal file
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
>foo :
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
class A {}
|
||||
>A : A
|
||||
}
|
||||
export = foo;
|
||||
>foo : foo
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : typeof x
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a: number }
|
||||
>A : A
|
||||
>a : number
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : typeof x
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = a.a;
|
||||
>b : number
|
||||
>a.a : number
|
||||
>a : x.A
|
||||
>a : number
|
||||
|
||||
19
tests/cases/compiler/augmentExportEquals1.ts
Normal file
19
tests/cases/compiler/augmentExportEquals1.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// @module: amd
|
||||
// @filename: file1.ts
|
||||
var x = 1;
|
||||
export = x;
|
||||
|
||||
// @filename: file2.ts
|
||||
|
||||
import x = require("./file1");
|
||||
|
||||
// augmentation for './file1'
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
22
tests/cases/compiler/augmentExportEquals1_1.ts
Normal file
22
tests/cases/compiler/augmentExportEquals1_1.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
var x: number;
|
||||
export = x;
|
||||
}
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// augmentation for 'file1'
|
||||
// should error since 'file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
19
tests/cases/compiler/augmentExportEquals2.ts
Normal file
19
tests/cases/compiler/augmentExportEquals2.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
function foo() {}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
// @filename: file3.ts
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
22
tests/cases/compiler/augmentExportEquals2_1.ts
Normal file
22
tests/cases/compiler/augmentExportEquals2_1.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
export = foo;
|
||||
}
|
||||
|
||||
// @filename: file2.ts
|
||||
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
24
tests/cases/compiler/augmentExportEquals3.ts
Normal file
24
tests/cases/compiler/augmentExportEquals3.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
function foo() {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
27
tests/cases/compiler/augmentExportEquals3_1.ts
Normal file
27
tests/cases/compiler/augmentExportEquals3_1.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// @module: amd
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
24
tests/cases/compiler/augmentExportEquals4.ts
Normal file
24
tests/cases/compiler/augmentExportEquals4.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
28
tests/cases/compiler/augmentExportEquals4_1.ts
Normal file
28
tests/cases/compiler/augmentExportEquals4_1.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
82
tests/cases/compiler/augmentExportEquals5.ts
Normal file
82
tests/cases/compiler/augmentExportEquals5.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: express.d.ts
|
||||
|
||||
declare module Express {
|
||||
export interface Request { }
|
||||
export interface Response { }
|
||||
export interface Application { }
|
||||
}
|
||||
|
||||
declare module "express" {
|
||||
function e(): e.Express;
|
||||
namespace e {
|
||||
interface IRoute {
|
||||
all(...handler: RequestHandler[]): IRoute;
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
(name: string|RegExp, ...handlers: RequestHandler[]): T;
|
||||
}
|
||||
|
||||
interface IRouter<T> extends RequestHandler {
|
||||
route(path: string): IRoute;
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
|
||||
export interface Router extends IRouter<Router> {}
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
|
||||
interface Request extends Express.Request {
|
||||
|
||||
get (name: string): string;
|
||||
}
|
||||
|
||||
interface Response extends Express.Response {
|
||||
charset: string;
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
(err: any, req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
(req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface Handler extends RequestHandler {}
|
||||
|
||||
interface RequestParamHandler {
|
||||
(req: Request, res: Response, next: Function, param: any): any;
|
||||
}
|
||||
|
||||
interface Application extends IRouter<Application>, Express.Application {
|
||||
routes: any;
|
||||
}
|
||||
|
||||
interface Express extends Application {
|
||||
createApplication(): Application;
|
||||
}
|
||||
|
||||
var static: any;
|
||||
}
|
||||
|
||||
export = e;
|
||||
}
|
||||
|
||||
// @filename: augmentation.ts
|
||||
/// <reference path="express.d.ts"/>
|
||||
import * as e from "express";
|
||||
declare module "express" {
|
||||
interface Request {
|
||||
id: number;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: consumer.ts
|
||||
import { Request } from "express";
|
||||
import "./augmentation";
|
||||
let x: Request;
|
||||
const y = x.id;
|
||||
28
tests/cases/compiler/augmentExportEquals6.ts
Normal file
28
tests/cases/compiler/augmentExportEquals6.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export class A {}
|
||||
export namespace B { export let a; }
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.B.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a: number }
|
||||
namespace B {
|
||||
export let b: number;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
let c = x.B.b;
|
||||
26
tests/cases/compiler/augmentExportEquals6_1.ts
Normal file
26
tests/cases/compiler/augmentExportEquals6_1.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
class A {}
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a: number }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
Reference in New Issue
Block a user