Commit 6338cb7
fix(compiler-cli): do not fail fatal when references to non-existent module are discovered (angular#58515)
Currently when application source code references e.g. an NgModule that
points to references that aren't available, the compiler will break at
runtime without any actionable/reasonable error.
This could happen for example when a library is referenced in code, but
the library is simply not available in the `node_modules`. Clearly,
TypeScript would issue import diagnostics here, but the Angular compiler
shouldn't break fatally. This is useful for migrations which may run
against projects which aren't fully compilable. The compiler handles
this fine in all cases, except when processing `.d.ts` currently... and
the runtime exception invalides all other information of the program
etc.
This commit fixes this by degrading such unexpected cases for `.d.ts`
metadata reading to be handled gracefully. This matches existing logic
where the `.d.ts` doesn't necessarily match the "expecation"/"expected
format".
The worst case is that the Angular compiler will not have type
information for some directives of e.g. a library that just isn't
installed in local `node_modules`; compared to magical errors and
unexpected runtime behavior.
PR Close angular#585151 parent 8d5d5f8 commit 6338cb7
File tree
9 files changed
+194
-26
lines changed- packages/compiler-cli
- src/ngtsc
- annotations/ng_module/src
- metadata
- src
- test
- reflection/src
- scope
- src
- test
- test/ngtsc
9 files changed
+194
-26
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
| 737 | + | |
737 | 738 | | |
738 | 739 | | |
739 | 740 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
79 | 102 | | |
80 | 103 | | |
81 | 104 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| |||
156 | 176 | | |
157 | 177 | | |
158 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
159 | 184 | | |
160 | 185 | | |
161 | 186 | | |
| |||
166 | 191 | | |
167 | 192 | | |
168 | 193 | | |
169 | | - | |
| 194 | + | |
170 | 195 | | |
171 | 196 | | |
172 | 197 | | |
173 | | - | |
| 198 | + | |
174 | 199 | | |
175 | 200 | | |
176 | 201 | | |
| |||
330 | 355 | | |
331 | 356 | | |
332 | 357 | | |
333 | | - | |
| 358 | + | |
334 | 359 | | |
335 | 360 | | |
336 | 361 | | |
337 | 362 | | |
338 | 363 | | |
| 364 | + | |
339 | 365 | | |
340 | 366 | | |
341 | 367 | | |
| |||
345 | 371 | | |
346 | 372 | | |
347 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
348 | 380 | | |
349 | | - | |
| 381 | + | |
350 | 382 | | |
351 | 383 | | |
352 | 384 | | |
353 | 385 | | |
354 | 386 | | |
355 | 387 | | |
356 | 388 | | |
357 | | - | |
| 389 | + | |
358 | 390 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
50 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
51 | 65 | | |
52 | 66 | | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
58 | | - | |
| 72 | + | |
59 | 73 | | |
60 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
61 | 90 | | |
62 | 91 | | |
63 | 92 | | |
| 93 | + | |
64 | 94 | | |
65 | 95 | | |
66 | 96 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
340 | 378 | | |
Lines changed: 16 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
536 | 542 | | |
537 | 543 | | |
538 | 544 | | |
539 | 545 | | |
540 | 546 | | |
541 | 547 | | |
542 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
543 | 551 | | |
544 | 552 | | |
545 | 553 | | |
| |||
551 | 559 | | |
552 | 560 | | |
553 | 561 | | |
554 | | - | |
| 562 | + | |
555 | 563 | | |
556 | 564 | | |
557 | 565 | | |
558 | 566 | | |
559 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
560 | 570 | | |
561 | 571 | | |
562 | 572 | | |
563 | 573 | | |
564 | 574 | | |
565 | 575 | | |
566 | 576 | | |
567 | | - | |
| 577 | + | |
568 | 578 | | |
569 | 579 | | |
570 | 580 | | |
571 | 581 | | |
572 | 582 | | |
573 | 583 | | |
574 | | - | |
| 584 | + | |
575 | 585 | | |
576 | 586 | | |
577 | 587 | | |
578 | 588 | | |
579 | 589 | | |
580 | | - | |
| 590 | + | |
581 | 591 | | |
582 | 592 | | |
583 | 593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
0 commit comments