@@ -99,13 +99,34 @@ module ts {
99
99
assert . equal ( resolution . failedLookupLocations . length , supportedTypeScriptExtensions . length ) ;
100
100
}
101
101
102
- it ( "module name as directory - load from typings" , ( ) => {
102
+ it ( "module name as directory - load from ' typings' " , ( ) => {
103
103
testLoadingFromPackageJson ( "/a/b/c/d.ts" , "/a/b/c/bar/package.json" , "c/d/e.d.ts" , "/a/b/c/bar/c/d/e.d.ts" , "./bar" ) ;
104
104
testLoadingFromPackageJson ( "/a/b/c/d.ts" , "/a/bar/package.json" , "e.d.ts" , "/a/bar/e.d.ts" , "../../bar" ) ;
105
105
testLoadingFromPackageJson ( "/a/b/c/d.ts" , "/bar/package.json" , "e.d.ts" , "/bar/e.d.ts" , "/bar" ) ;
106
106
testLoadingFromPackageJson ( "c:/a/b/c/d.ts" , "c:/bar/package.json" , "e.d.ts" , "c:/bar/e.d.ts" , "c:/bar" ) ;
107
107
} ) ;
108
108
109
+ function testTypingsIgnored ( typings : any ) : void {
110
+ let containingFile = { name : "/a/b.ts" } ;
111
+ let packageJson = { name : "/node_modules/b/package.json" , content : JSON . stringify ( { "typings" : typings } ) } ;
112
+ let moduleFile = { name : "/a/b.d.ts" } ;
113
+
114
+ let indexPath = "/node_modules/b/index.d.ts" ;
115
+ let indexFile = { name : indexPath }
116
+
117
+ let resolution = nodeModuleNameResolver ( "b" , containingFile . name , { } , createModuleResolutionHost ( containingFile , packageJson , moduleFile , indexFile ) ) ;
118
+
119
+ assert . equal ( resolution . resolvedModule . resolvedFileName , indexPath ) ;
120
+ }
121
+
122
+ it ( "module name as directory - handle invalid 'typings'" , ( ) => {
123
+ testTypingsIgnored ( [ "a" , "b" ] ) ;
124
+ testTypingsIgnored ( { "a" : "b" } ) ;
125
+ testTypingsIgnored ( true ) ;
126
+ testTypingsIgnored ( null ) ;
127
+ testTypingsIgnored ( undefined ) ;
128
+ } ) ;
129
+
109
130
it ( "module name as directory - load index.d.ts" , ( ) => {
110
131
let containingFile = { name : "/a/b/c.ts" } ;
111
132
let packageJson = { name : "/a/b/foo/package.json" , content : JSON . stringify ( { main : "/c/d" } ) } ;
0 commit comments