diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 373c3782411..c863f7e8963 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4718,7 +4718,13 @@ module ts { var pathMatchResult = pathRegex.exec(comment); var nameMatchResult = nameRegex.exec(comment); if (pathMatchResult) { - amdDependencies.push({path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined }); + var amdDependency = {path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined }; + // AMD dependencies with names have to go first in define header + if (nameMatchResult) { + amdDependencies.push(amdDependency); + } else { + amdDependencies.unshift(amdDependency); + } } } } diff --git a/tests/baselines/reference/amdDependencyCommentName3.errors.txt b/tests/baselines/reference/amdDependencyCommentName3.errors.txt new file mode 100644 index 00000000000..1fa997b9c99 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/amdDependencyCommentName3.ts(5,21): error TS2307: Cannot find external module 'm2'. + + +==== tests/cases/compiler/amdDependencyCommentName3.ts (1 errors) ==== + /// + /// + /// + + import m1 = require("m2") + ~~~~ +!!! error TS2307: Cannot find external module 'm2'. + m1.f(); \ No newline at end of file diff --git a/tests/baselines/reference/amdDependencyCommentName3.js b/tests/baselines/reference/amdDependencyCommentName3.js new file mode 100644 index 00000000000..53ac77537f1 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName3.js @@ -0,0 +1,15 @@ +//// [amdDependencyCommentName3.ts] +/// +/// +/// + +import m1 = require("m2") +m1.f(); + +//// [amdDependencyCommentName3.js] +/// +/// +/// +define(["require", "exports", "m2", "foo", "bar", "goo"], function (require, exports, m1, b, c) { + m1.f(); +}); diff --git a/tests/cases/compiler/amdDependencyCommentName3.ts b/tests/cases/compiler/amdDependencyCommentName3.ts new file mode 100644 index 00000000000..4800aed9639 --- /dev/null +++ b/tests/cases/compiler/amdDependencyCommentName3.ts @@ -0,0 +1,7 @@ +//@module: amd +/// +/// +/// + +import m1 = require("m2") +m1.f(); \ No newline at end of file