Skip to content

Commit 843d3ec

Browse files
committed
Added a compiler test for named AMD modules.
1 parent 2302bd2 commit 843d3ec

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,14 +2097,10 @@ module ts {
20972097
var imports = getExternalImportDeclarations(node);
20982098
writeLine();
20992099
write("define(");
2100-
21012100
if(node.amdModuleName) {
2102-
write("\"" + node.amdModuleName + "\"");
2103-
write(", ");
2101+
write("\"" + node.amdModuleName + "\", ");
21042102
}
2105-
21062103
write("[\"require\", \"exports\"");
2107-
21082104
forEach(imports, imp => {
21092105
write(", ");
21102106
emitLiteral(imp.externalModuleName);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [amdModuleName1.ts]
2+
///<amd-module name='NamedModule'/>
3+
class Foo {
4+
x: number;
5+
constructor() {
6+
this.x = 5;
7+
}
8+
}
9+
export = Foo;
10+
11+
12+
//// [amdModuleName1.js]
13+
define("NamedModule", ["require", "exports"], function (require, exports) {
14+
///<amd-module name='NamedModule'/>
15+
var Foo = (function () {
16+
function Foo() {
17+
this.x = 5;
18+
}
19+
return Foo;
20+
})();
21+
return Foo;
22+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/amdModuleName1.ts ===
2+
///<amd-module name='NamedModule'/>
3+
class Foo {
4+
>Foo : Foo
5+
6+
x: number;
7+
>x : number
8+
9+
constructor() {
10+
this.x = 5;
11+
>this.x = 5 : number
12+
>this.x : number
13+
>this : Foo
14+
>x : number
15+
}
16+
}
17+
export = Foo;
18+
>Foo : Foo
19+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@module: amd
2+
///<amd-module name='NamedModule'/>
3+
class Foo {
4+
x: number;
5+
constructor() {
6+
this.x = 5;
7+
}
8+
}
9+
export = Foo;

0 commit comments

Comments
 (0)