@@ -1027,6 +1027,8 @@ namespace ts.projectSystem {
1027
1027
} ) ;
1028
1028
1029
1029
describe ( "discover typings" , ( ) => {
1030
+ const emptySafeList = emptyMap ;
1031
+
1030
1032
it ( "should use mappings from safe list" , ( ) => {
1031
1033
const app = {
1032
1034
path : "/a/b/app.js" ,
@@ -1040,11 +1042,12 @@ namespace ts.projectSystem {
1040
1042
path : "/a/b/chroma.min.js" ,
1041
1043
content : ""
1042
1044
} ;
1043
- const cache = createMap < string > ( ) ;
1045
+
1046
+ const safeList = createMapFromTemplate ( { jquery : "jquery" , chroma : "chroma-js" } ) ;
1044
1047
1045
1048
const host = createServerHost ( [ app , jquery , chroma ] ) ;
1046
1049
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 ) ;
1048
1051
assert . deepEqual ( logger . finish ( ) , [
1049
1052
'Inferred typings from file names: ["jquery","chroma-js"]' ,
1050
1053
'Result: {"cachedTypingPaths":[],"newTypingNames":["jquery","chroma-js"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1062,7 +1065,7 @@ namespace ts.projectSystem {
1062
1065
1063
1066
for ( const name of JsTyping . nodeCoreModuleList ) {
1064
1067
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" ] ) ;
1066
1069
assert . deepEqual ( logger . finish ( ) , [
1067
1070
'Inferred typings from unresolved imports: ["node","somename"]' ,
1068
1071
'Result: {"cachedTypingPaths":[],"newTypingNames":["node","somename"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1083,7 +1086,7 @@ namespace ts.projectSystem {
1083
1086
const host = createServerHost ( [ f , node ] ) ;
1084
1087
const cache = createMapFromTemplate < string > ( { "node" : node . path } ) ;
1085
1088
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" ] ) ;
1087
1090
assert . deepEqual ( logger . finish ( ) , [
1088
1091
'Inferred typings from unresolved imports: ["node","bar"]' ,
1089
1092
'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 {
1108
1111
const host = createServerHost ( [ app , a , b ] ) ;
1109
1112
const cache = createMap < string > ( ) ;
1110
1113
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*/ [ ] ) ;
1112
1115
assert . deepEqual ( logger . finish ( ) , [
1113
1116
'Searching for typing names in /node_modules; all files: ["/node_modules/a/package.json"]' ,
1114
1117
'Result: {"cachedTypingPaths":[],"newTypingNames":["a"],"filesToWatch":["/bower_components","/node_modules"]}' ,
0 commit comments