mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Merge pull request #6906 from Microsoft/port-6858
Ports #6858 into release-1.8
This commit is contained in:
@@ -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 ");
|
||||
|
||||
@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClause_0";
|
||||
//// [es6ImportWithoutFromClause_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClause_1.d.ts]
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -18,3 +18,4 @@ require("es6ImportWithoutFromClauseInEs5_0");
|
||||
//// [es6ImportWithoutFromClauseInEs5_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClauseInEs5_1.d.ts]
|
||||
import "es6ImportWithoutFromClauseInEs5_0";
|
||||
|
||||
@@ -17,3 +17,4 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
||||
export interface i {
|
||||
}
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts]
|
||||
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
||||
|
||||
16
tests/baselines/reference/keepImportsInDts1.js
Normal file
16
tests/baselines/reference/keepImportsInDts1.js
Normal 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";
|
||||
6
tests/baselines/reference/keepImportsInDts1.symbols
Normal file
6
tests/baselines/reference/keepImportsInDts1.symbols
Normal 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.
|
||||
6
tests/baselines/reference/keepImportsInDts1.types
Normal file
6
tests/baselines/reference/keepImportsInDts1.types
Normal 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.
|
||||
22
tests/baselines/reference/keepImportsInDts2.js
Normal file
22
tests/baselines/reference/keepImportsInDts2.js
Normal 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";
|
||||
6
tests/baselines/reference/keepImportsInDts2.symbols
Normal file
6
tests/baselines/reference/keepImportsInDts2.symbols
Normal 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.
|
||||
6
tests/baselines/reference/keepImportsInDts2.types
Normal file
6
tests/baselines/reference/keepImportsInDts2.types
Normal 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.
|
||||
24
tests/baselines/reference/keepImportsInDts3.js
Normal file
24
tests/baselines/reference/keepImportsInDts3.js
Normal 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";
|
||||
}
|
||||
6
tests/baselines/reference/keepImportsInDts3.symbols
Normal file
6
tests/baselines/reference/keepImportsInDts3.symbols
Normal 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.
|
||||
6
tests/baselines/reference/keepImportsInDts3.types
Normal file
6
tests/baselines/reference/keepImportsInDts3.types
Normal 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.
|
||||
24
tests/baselines/reference/keepImportsInDts4.js
Normal file
24
tests/baselines/reference/keepImportsInDts4.js
Normal 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";
|
||||
}
|
||||
6
tests/baselines/reference/keepImportsInDts4.symbols
Normal file
6
tests/baselines/reference/keepImportsInDts4.symbols
Normal 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.
|
||||
6
tests/baselines/reference/keepImportsInDts4.types
Normal file
6
tests/baselines/reference/keepImportsInDts4.types
Normal 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.
|
||||
@@ -73,3 +73,5 @@ declare module "./observable" {
|
||||
}
|
||||
export {};
|
||||
//// [main.d.ts]
|
||||
import "./map1";
|
||||
import "./map2";
|
||||
|
||||
@@ -66,3 +66,4 @@ declare module "./observable" {
|
||||
}
|
||||
export {};
|
||||
//// [main.d.ts]
|
||||
import "./map";
|
||||
|
||||
@@ -71,3 +71,4 @@ declare module "./observable" {
|
||||
}
|
||||
export {};
|
||||
//// [main.d.ts]
|
||||
import "./map";
|
||||
|
||||
@@ -63,3 +63,4 @@ declare module "observable" {
|
||||
export {};
|
||||
//// [main.d.ts]
|
||||
/// <reference path="observable.d.ts" />
|
||||
import "./map";
|
||||
|
||||
@@ -50,3 +50,4 @@ declare global {
|
||||
}
|
||||
export {};
|
||||
//// [f3.d.ts]
|
||||
import "./f2";
|
||||
|
||||
@@ -45,3 +45,5 @@ declare global {
|
||||
export { };
|
||||
export {};
|
||||
//// [f3.d.ts]
|
||||
import "./f1";
|
||||
import "./f2";
|
||||
|
||||
@@ -32,3 +32,5 @@ require("B");
|
||||
//// [f3.d.ts]
|
||||
/// <reference path="f1.d.ts" />
|
||||
/// <reference path="f2.d.ts" />
|
||||
import "A";
|
||||
import "B";
|
||||
|
||||
@@ -69,3 +69,4 @@ declare module "./f1" {
|
||||
}
|
||||
}
|
||||
//// [f4.d.ts]
|
||||
import "./f3";
|
||||
|
||||
@@ -74,3 +74,4 @@ export declare class B {
|
||||
n: number;
|
||||
}
|
||||
//// [f4.d.ts]
|
||||
import "./f3";
|
||||
|
||||
@@ -72,3 +72,4 @@ export declare class B {
|
||||
n: number;
|
||||
}
|
||||
//// [f4.d.ts]
|
||||
import "./f3";
|
||||
|
||||
@@ -76,3 +76,4 @@ export declare class B {
|
||||
n: number;
|
||||
}
|
||||
//// [f4.d.ts]
|
||||
import "./f3";
|
||||
|
||||
@@ -95,3 +95,4 @@ declare module "./f1" {
|
||||
}
|
||||
}
|
||||
//// [f4.d.ts]
|
||||
import "./f3";
|
||||
|
||||
@@ -33,3 +33,4 @@ var y = x.getA().x;
|
||||
|
||||
//// [f.d.ts]
|
||||
/// <reference path="array.d.ts" />
|
||||
import "array";
|
||||
|
||||
@@ -139,4 +139,6 @@ declare module "m4" {
|
||||
}
|
||||
}
|
||||
declare module "test" {
|
||||
import "m2";
|
||||
import "m4";
|
||||
}
|
||||
|
||||
@@ -101,4 +101,5 @@ declare module "d" {
|
||||
}
|
||||
}
|
||||
declare module "main" {
|
||||
import "d";
|
||||
}
|
||||
|
||||
@@ -111,4 +111,6 @@ declare module "e" {
|
||||
}
|
||||
}
|
||||
declare module "main" {
|
||||
import "d";
|
||||
import "e";
|
||||
}
|
||||
|
||||
@@ -98,4 +98,6 @@ declare module "e" {
|
||||
}
|
||||
}
|
||||
declare module "main" {
|
||||
import "D";
|
||||
import "e";
|
||||
}
|
||||
|
||||
@@ -87,4 +87,6 @@ declare module "b" {
|
||||
}
|
||||
}
|
||||
declare module "main" {
|
||||
import "D";
|
||||
import "E";
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/noErrorOnEmptyDts.ts] ////
|
||||
|
||||
//// [test.d.ts]
|
||||
|
||||
|
||||
// comment
|
||||
|
||||
//// [main.ts]
|
||||
import "test"
|
||||
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
require("test");
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
7
tests/cases/compiler/keepImportsInDts1.ts
Normal file
7
tests/cases/compiler/keepImportsInDts1.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// @module: amd
|
||||
// @declaration: true
|
||||
|
||||
// @filename: c:/test.d.ts
|
||||
export {};
|
||||
// @filename: c:/app/main.ts
|
||||
import "test"
|
||||
7
tests/cases/compiler/keepImportsInDts2.ts
Normal file
7
tests/cases/compiler/keepImportsInDts2.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// @module: amd
|
||||
// @declaration: true
|
||||
|
||||
// @filename: folder/test.ts
|
||||
export {};
|
||||
// @filename: main.ts
|
||||
import "./folder/test"
|
||||
8
tests/cases/compiler/keepImportsInDts3.ts
Normal file
8
tests/cases/compiler/keepImportsInDts3.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @module: amd
|
||||
// @declaration: true
|
||||
// @out: outputfile.js
|
||||
|
||||
// @filename: c:/test.ts
|
||||
export {};
|
||||
// @filename: c:/app/main.ts
|
||||
import "test"
|
||||
8
tests/cases/compiler/keepImportsInDts4.ts
Normal file
8
tests/cases/compiler/keepImportsInDts4.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @module: amd
|
||||
// @declaration: true
|
||||
// @out: outputfile.js
|
||||
|
||||
// @filename: folder/test.ts
|
||||
export {};
|
||||
// @filename: main.ts
|
||||
import "./folder/test"
|
||||
@@ -1,8 +0,0 @@
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: c:/node_modules/test.d.ts
|
||||
|
||||
// comment
|
||||
|
||||
// @filename: c:/app/main.ts
|
||||
import "test"
|
||||
Reference in New Issue
Block a user