mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added AMD dependency reordering, so import order matches with provided names
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) ====
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
///<amd-dependency path='foo'/>
|
||||
///<amd-dependency path='goo' name='c'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
~~~~
|
||||
!!! error TS2307: Cannot find external module 'm2'.
|
||||
m1.f();
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [amdDependencyCommentName3.ts]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
///<amd-dependency path='foo'/>
|
||||
///<amd-dependency path='goo' name='c'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
||||
|
||||
//// [amdDependencyCommentName3.js]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
///<amd-dependency path='foo'/>
|
||||
///<amd-dependency path='goo' name='c'/>
|
||||
define(["require", "exports", "m2", "foo", "bar", "goo"], function (require, exports, m1, b, c) {
|
||||
m1.f();
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
//@module: amd
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
///<amd-dependency path='foo'/>
|
||||
///<amd-dependency path='goo' name='c'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
||||
Reference in New Issue
Block a user