Enable declaration emit for import "mod" syntax
This commit is contained in:
parent
67874b4c9e
commit
6ac1bcca08
|
@ -766,6 +766,18 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function emitImportDeclaration(node: ImportDeclaration) {
|
||||
// TODO(shkamat): Do the changes so that we emit only if declaration is visible
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
write("export ");
|
||||
}
|
||||
write("import ");
|
||||
writeTextOfNode(currentSourceFile, node.moduleSpecifier);
|
||||
write(";");
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
if (resolver.isDeclarationVisible(node)) {
|
||||
emitJsDocComments(node);
|
||||
|
@ -1483,6 +1495,8 @@ module ts {
|
|||
return emitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return emitExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return emitImportDeclaration(<ImportDeclaration>node);
|
||||
case SyntaxKind.SourceFile:
|
||||
return emitSourceFile(<SourceFile>node);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,16 @@
|
|||
export var a = 10;
|
||||
|
||||
//// [es6ImportWithoutFromClause_1.ts]
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClause_0.js]
|
||||
exports.a = 10;
|
||||
//// [es6ImportWithoutFromClause_1.js]
|
||||
require("es6ImportWithoutFromClause_0");
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClause_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClause_1.d.ts]
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
|
|
@ -5,4 +5,5 @@ export var a = 10;
|
|||
|
||||
=== tests/cases/compiler/es6ImportWithoutFromClause_1.ts ===
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
No type information for this code.
|
||||
No type information for this code.
|
37
tests/baselines/reference/es6ImportWithoutFromClauseAmd.js
Normal file
37
tests/baselines/reference/es6ImportWithoutFromClauseAmd.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
//// [tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts] ////
|
||||
|
||||
//// [es6ImportWithoutFromClauseAmd_0.ts]
|
||||
|
||||
export var a = 10;
|
||||
|
||||
//// [es6ImportWithoutFromClauseAmd_1.ts]
|
||||
export var b = 10;
|
||||
|
||||
//// [es6ImportWithoutFromClauseAmd_2.ts]
|
||||
import "es6ImportWithoutFromClauseAmd_0";
|
||||
import "es6ImportWithoutFromClauseAmd_2";
|
||||
var _a = 10;
|
||||
var _b = 10;
|
||||
|
||||
//// [es6ImportWithoutFromClauseAmd_0.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.a = 10;
|
||||
});
|
||||
//// [es6ImportWithoutFromClauseAmd_1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.b = 10;
|
||||
});
|
||||
//// [es6ImportWithoutFromClauseAmd_2.js]
|
||||
define(["require", "exports", "es6ImportWithoutFromClauseAmd_0", "es6ImportWithoutFromClauseAmd_2"], function (require, exports, _c, _d) {
|
||||
var _a = 10;
|
||||
var _b = 10;
|
||||
});
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClauseAmd_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClauseAmd_1.d.ts]
|
||||
export declare var b: number;
|
||||
//// [es6ImportWithoutFromClauseAmd_2.d.ts]
|
||||
import "es6ImportWithoutFromClauseAmd_0";
|
||||
import "es6ImportWithoutFromClauseAmd_2";
|
|
@ -0,0 +1,18 @@
|
|||
=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : number
|
||||
|
||||
=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_1.ts ===
|
||||
export var b = 10;
|
||||
>b : number
|
||||
|
||||
=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_2.ts ===
|
||||
import "es6ImportWithoutFromClauseAmd_0";
|
||||
import "es6ImportWithoutFromClauseAmd_2";
|
||||
var _a = 10;
|
||||
>_a : number
|
||||
|
||||
var _b = 10;
|
||||
>_b : number
|
||||
|
|
@ -11,3 +11,9 @@ import "es6ImportWithoutFromClauseInEs5_0";
|
|||
exports.a = 10;
|
||||
//// [es6ImportWithoutFromClauseInEs5_1.js]
|
||||
require("es6ImportWithoutFromClauseInEs5_0");
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClauseInEs5_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClauseInEs5_1.d.ts]
|
||||
import "es6ImportWithoutFromClauseInEs5_0";
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
//// [tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts] ////
|
||||
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.ts]
|
||||
|
||||
export interface i {
|
||||
}
|
||||
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.ts]
|
||||
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
||||
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.js]
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.js]
|
||||
require("es6ImportWithoutFromClauseNonInstantiatedModule_0");
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.d.ts]
|
||||
export interface i {
|
||||
}
|
||||
//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts]
|
||||
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_0.ts ===
|
||||
|
||||
export interface i {
|
||||
>i : i
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_1.ts ===
|
||||
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
||||
No type information for this code.
|
|
@ -1,8 +1,9 @@
|
|||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportWithoutFromClause_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportWithoutFromClause_1.ts
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
|
14
tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts
Normal file
14
tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
// @module: amd
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseAmd_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseAmd_1.ts
|
||||
export var b = 10;
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseAmd_2.ts
|
||||
import "es6ImportWithoutFromClauseAmd_0";
|
||||
import "es6ImportWithoutFromClauseAmd_2";
|
||||
var _a = 10;
|
||||
var _b = 10;
|
|
@ -1,5 +1,6 @@
|
|||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseInEs5_0.ts
|
||||
export var a = 10;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_0.ts
|
||||
export interface i {
|
||||
}
|
||||
|
||||
// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_1.ts
|
||||
import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
|
Loading…
Reference in a new issue