@@ -1027,6 +1027,8 @@ namespace ts.projectSystem {
10271027 } ) ;
10281028
10291029 describe ( "discover typings" , ( ) => {
1030+ const emptySafeList = emptyMap ;
1031+
10301032 it ( "should use mappings from safe list" , ( ) => {
10311033 const app = {
10321034 path : "/a/b/app.js" ,
@@ -1040,11 +1042,12 @@ namespace ts.projectSystem {
10401042 path : "/a/b/chroma.min.js" ,
10411043 content : ""
10421044 } ;
1043- const cache = createMap < string > ( ) ;
1045+
1046+ const safeList = createMapFromTemplate ( { jquery : "jquery" , chroma : "chroma-js" } ) ;
10441047
10451048 const host = createServerHost ( [ app , jquery , chroma ] ) ;
10461049 const logger = trackingLogger ( ) ;
1047- const result = JsTyping . discoverTypings ( host , logger . log , [ app . path , jquery . path , chroma . path ] , getDirectoryPath ( < Path > app . path ) , /*safeListPath*/ undefined , cache , { enable : true } , [ ] ) ;
1050+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path , jquery . path , chroma . path ] , getDirectoryPath ( < Path > app . path ) , safeList , emptyMap , { enable : true } , emptyArray ) ;
10481051 assert . deepEqual ( logger . finish ( ) , [
10491052 'Inferred typings from file names: ["jquery","chroma-js"]' ,
10501053 'Result: {"cachedTypingPaths":[],"newTypingNames":["jquery","chroma-js"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1062,7 +1065,7 @@ namespace ts.projectSystem {
10621065
10631066 for ( const name of JsTyping . nodeCoreModuleList ) {
10641067 const logger = trackingLogger ( ) ;
1065- const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , /*safeListPath*/ undefined , cache , { enable : true } , [ name , "somename" ] ) ;
1068+ const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ name , "somename" ] ) ;
10661069 assert . deepEqual ( logger . finish ( ) , [
10671070 'Inferred typings from unresolved imports: ["node","somename"]' ,
10681071 'Result: {"cachedTypingPaths":[],"newTypingNames":["node","somename"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1083,7 +1086,7 @@ namespace ts.projectSystem {
10831086 const host = createServerHost ( [ f , node ] ) ;
10841087 const cache = createMapFromTemplate < string > ( { "node" : node . path } ) ;
10851088 const logger = trackingLogger ( ) ;
1086- const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , /*safeListPath*/ undefined , cache , { enable : true } , [ "fs" , "bar" ] ) ;
1089+ const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ "fs" , "bar" ] ) ;
10871090 assert . deepEqual ( logger . finish ( ) , [
10881091 'Inferred typings from unresolved imports: ["node","bar"]' ,
10891092 'Result: {"cachedTypingPaths":["/a/b/node.d.ts"],"newTypingNames":["bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1108,7 +1111,7 @@ namespace ts.projectSystem {
11081111 const host = createServerHost ( [ app , a , b ] ) ;
11091112 const cache = createMap < string > ( ) ;
11101113 const logger = trackingLogger ( ) ;
1111- const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , /*safeListPath*/ undefined , cache , { enable : true } , /*unresolvedImports*/ [ ] ) ;
1114+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , /*unresolvedImports*/ [ ] ) ;
11121115 assert . deepEqual ( logger . finish ( ) , [
11131116 'Searching for typing names in /node_modules; all files: ["/node_modules/a/package.json"]' ,
11141117 'Result: {"cachedTypingPaths":[],"newTypingNames":["a"],"filesToWatch":["/bower_components","/node_modules"]}' ,
0 commit comments