Merge pull request #6906 from Microsoft/port-6858

Ports #6858 into release-1.8
This commit is contained in:
Vladimir Matveev
2016-02-04 12:46:43 -08:00
43 changed files with 194 additions and 41 deletions

View File

@@ -695,10 +695,6 @@ namespace ts {
}
function writeImportDeclaration(node: ImportDeclaration) {
if (!node.importClause && !(node.flags & NodeFlags.Export)) {
// do not write non-exported import declarations that don't have import clauses
return;
}
emitJsDocComments(node);
if (node.flags & NodeFlags.Export) {
write("export ");

View File

@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClause_0";
//// [es6ImportWithoutFromClause_0.d.ts]
export declare var a: number;
//// [es6ImportWithoutFromClause_1.d.ts]
import "es6ImportWithoutFromClause_0";

View File

@@ -36,3 +36,5 @@ export declare var a: number;
//// [es6ImportWithoutFromClauseAmd_1.d.ts]
export declare var b: number;
//// [es6ImportWithoutFromClauseAmd_2.d.ts]
import "es6ImportWithoutFromClauseAmd_0";
import "es6ImportWithoutFromClauseAmd_2";

View File

@@ -18,3 +18,4 @@ require("es6ImportWithoutFromClauseInEs5_0");
//// [es6ImportWithoutFromClauseInEs5_0.d.ts]
export declare var a: number;
//// [es6ImportWithoutFromClauseInEs5_1.d.ts]
import "es6ImportWithoutFromClauseInEs5_0";

View File

@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
export interface i {
}
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts]
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";

View File

@@ -0,0 +1,16 @@
//// [tests/cases/compiler/keepImportsInDts1.ts] ////
//// [test.d.ts]
export {};
//// [main.ts]
import "test"
//// [main.js]
define(["require", "exports", "test"], function (require, exports) {
"use strict";
});
//// [main.d.ts]
import "test";

View File

@@ -0,0 +1,6 @@
=== c:/test.d.ts ===
No type information for this code.export {};
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -0,0 +1,6 @@
=== c:/test.d.ts ===
No type information for this code.export {};
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -0,0 +1,22 @@
//// [tests/cases/compiler/keepImportsInDts2.ts] ////
//// [test.ts]
export {};
//// [main.ts]
import "./folder/test"
//// [test.js]
define(["require", "exports"], function (require, exports) {
"use strict";
});
//// [main.js]
define(["require", "exports", "./folder/test"], function (require, exports) {
"use strict";
});
//// [test.d.ts]
export { };
//// [main.d.ts]
import "./folder/test";

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/folder/test.ts ===
No type information for this code.export {};
No type information for this code.=== tests/cases/compiler/main.ts ===
import "./folder/test"
No type information for this code.

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/folder/test.ts ===
No type information for this code.export {};
No type information for this code.=== tests/cases/compiler/main.ts ===
import "./folder/test"
No type information for this code.

View File

@@ -0,0 +1,24 @@
//// [tests/cases/compiler/keepImportsInDts3.ts] ////
//// [test.ts]
export {};
//// [main.ts]
import "test"
//// [outputfile.js]
define("test", ["require", "exports"], function (require, exports) {
"use strict";
});
define("app/main", ["require", "exports", "test"], function (require, exports) {
"use strict";
});
//// [outputfile.d.ts]
declare module "test" {
export { };
}
declare module "app/main" {
import "test";
}

View File

@@ -0,0 +1,6 @@
=== c:/test.ts ===
No type information for this code.export {};
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -0,0 +1,6 @@
=== c:/test.ts ===
No type information for this code.export {};
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -0,0 +1,24 @@
//// [tests/cases/compiler/keepImportsInDts4.ts] ////
//// [test.ts]
export {};
//// [main.ts]
import "./folder/test"
//// [outputfile.js]
define("folder/test", ["require", "exports"], function (require, exports) {
"use strict";
});
define("main", ["require", "exports", "folder/test"], function (require, exports) {
"use strict";
});
//// [outputfile.d.ts]
declare module "folder/test" {
export { };
}
declare module "main" {
import "folder/test";
}

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/folder/test.ts ===
No type information for this code.export {};
No type information for this code.=== tests/cases/compiler/main.ts ===
import "./folder/test"
No type information for this code.

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/folder/test.ts ===
No type information for this code.export {};
No type information for this code.=== tests/cases/compiler/main.ts ===
import "./folder/test"
No type information for this code.

View File

@@ -73,3 +73,5 @@ declare module "./observable" {
}
export {};
//// [main.d.ts]
import "./map1";
import "./map2";

View File

@@ -66,3 +66,4 @@ declare module "./observable" {
}
export {};
//// [main.d.ts]
import "./map";

View File

@@ -71,3 +71,4 @@ declare module "./observable" {
}
export {};
//// [main.d.ts]
import "./map";

View File

@@ -63,3 +63,4 @@ declare module "observable" {
export {};
//// [main.d.ts]
/// <reference path="observable.d.ts" />
import "./map";

View File

@@ -50,3 +50,4 @@ declare global {
}
export {};
//// [f3.d.ts]
import "./f2";

View File

@@ -45,3 +45,5 @@ declare global {
export { };
export {};
//// [f3.d.ts]
import "./f1";
import "./f2";

View File

@@ -32,3 +32,5 @@ require("B");
//// [f3.d.ts]
/// <reference path="f1.d.ts" />
/// <reference path="f2.d.ts" />
import "A";
import "B";

View File

@@ -69,3 +69,4 @@ declare module "./f1" {
}
}
//// [f4.d.ts]
import "./f3";

View File

@@ -74,3 +74,4 @@ export declare class B {
n: number;
}
//// [f4.d.ts]
import "./f3";

View File

@@ -72,3 +72,4 @@ export declare class B {
n: number;
}
//// [f4.d.ts]
import "./f3";

View File

@@ -76,3 +76,4 @@ export declare class B {
n: number;
}
//// [f4.d.ts]
import "./f3";

View File

@@ -95,3 +95,4 @@ declare module "./f1" {
}
}
//// [f4.d.ts]
import "./f3";

View File

@@ -33,3 +33,4 @@ var y = x.getA().x;
//// [f.d.ts]
/// <reference path="array.d.ts" />
import "array";

View File

@@ -139,4 +139,6 @@ declare module "m4" {
}
}
declare module "test" {
import "m2";
import "m4";
}

View File

@@ -101,4 +101,5 @@ declare module "d" {
}
}
declare module "main" {
import "d";
}

View File

@@ -111,4 +111,6 @@ declare module "e" {
}
}
declare module "main" {
import "d";
import "e";
}

View File

@@ -98,4 +98,6 @@ declare module "e" {
}
}
declare module "main" {
import "D";
import "e";
}

View File

@@ -87,4 +87,6 @@ declare module "b" {
}
}
declare module "main" {
import "D";
import "E";
}

View File

@@ -1,13 +0,0 @@
//// [tests/cases/compiler/noErrorOnEmptyDts.ts] ////
//// [test.d.ts]
// comment
//// [main.ts]
import "test"
//// [main.js]
"use strict";
require("test");

View File

@@ -1,8 +0,0 @@
=== c:/node_modules/test.d.ts ===
No type information for this code.
No type information for this code.// comment
No type information for this code.
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -1,8 +0,0 @@
=== c:/node_modules/test.d.ts ===
No type information for this code.
No type information for this code.// comment
No type information for this code.
No type information for this code.=== c:/app/main.ts ===
import "test"
No type information for this code.

View File

@@ -0,0 +1,7 @@
// @module: amd
// @declaration: true
// @filename: c:/test.d.ts
export {};
// @filename: c:/app/main.ts
import "test"

View File

@@ -0,0 +1,7 @@
// @module: amd
// @declaration: true
// @filename: folder/test.ts
export {};
// @filename: main.ts
import "./folder/test"

View File

@@ -0,0 +1,8 @@
// @module: amd
// @declaration: true
// @out: outputfile.js
// @filename: c:/test.ts
export {};
// @filename: c:/app/main.ts
import "test"

View File

@@ -0,0 +1,8 @@
// @module: amd
// @declaration: true
// @out: outputfile.js
// @filename: folder/test.ts
export {};
// @filename: main.ts
import "./folder/test"

View File

@@ -1,8 +0,0 @@
// @module: commonjs
// @filename: c:/node_modules/test.d.ts
// comment
// @filename: c:/app/main.ts
import "test"