@@ -44,7 +44,9 @@ impl FileAnalyzer for TsConfigAnalyzer {
44
44
// project scope
45
45
let proj_scope = if let Some ( proj_name) = proj_name {
46
46
let proj_scope_id = graph. new_node_id ( file) ;
47
- let proj_scope = graph. add_scope_node ( proj_scope_id, false ) . unwrap ( ) ;
47
+ let proj_scope = graph
48
+ . add_scope_node ( proj_scope_id, false )
49
+ . expect ( "no previous node for new id" ) ;
48
50
add_debug_name ( graph, proj_scope, "tsconfig.proj_scope" ) ;
49
51
50
52
// project definition
@@ -113,9 +115,12 @@ impl FileAnalyzer for TsConfigAnalyzer {
113
115
114
116
// path mappings
115
117
for ( from_idx, ( from, tos) ) in tsc. paths ( ) . iter ( ) . enumerate ( ) {
116
- let is_prefix = from. file_name ( ) . map_or ( true , |n| n == "*" ) ;
118
+ let is_prefix = from. file_name ( ) . map_or ( false , |n| n == "*" ) ;
117
119
let from = if is_prefix {
118
- from. parent ( ) . unwrap ( )
120
+ match from. parent ( ) {
121
+ Some ( from) => from,
122
+ None => continue ,
123
+ }
119
124
} else {
120
125
& from
121
126
} ;
@@ -128,7 +133,17 @@ impl FileAnalyzer for TsConfigAnalyzer {
128
133
& format ! ( "tsconfig.paths[{}].from_def" , from_idx) ,
129
134
) ;
130
135
for ( to_idx, to) in tos. iter ( ) . enumerate ( ) {
131
- let to = if is_prefix { to. parent ( ) . unwrap ( ) } else { & to } ;
136
+ if is_prefix && !to. file_name ( ) . map_or ( false , |n| n == "*" ) {
137
+ continue ;
138
+ }
139
+ let to = if is_prefix {
140
+ match to. parent ( ) {
141
+ Some ( to) => to,
142
+ None => continue ,
143
+ }
144
+ } else {
145
+ & to
146
+ } ;
132
147
let to_ref = add_module_pushes (
133
148
graph,
134
149
file,
@@ -274,7 +289,11 @@ impl TsConfig {
274
289
275
290
// compute patterns---invalid patterns are silently ignored
276
291
es. into_iter ( )
277
- . filter_map ( |e| Pattern :: new ( p. with_extension ( e) . to_str ( ) . unwrap ( ) ) . ok ( ) )
292
+ . filter_map ( |e| {
293
+ p. with_extension ( e)
294
+ . to_str ( )
295
+ . and_then ( |p| Pattern :: new ( p) . ok ( ) )
296
+ } )
278
297
. collect ( )
279
298
}
280
299
0 commit comments