Commit 8841cd8
authored
fix(unplugin-dts): correct module-resolution precedence in setModuleResolution (#486)
In setModuleResolution, `options.target ?? ts.ScriptTarget.ES5 >= 2` parsed as
`options.target ?? (ES5 >= 2)` = `options.target ?? false`, because `>=` binds
tighter than `??`. The resolved target was never compared: called in isolation
with an explicit low target (e.g. ES5), the helper picked ES2015 modules instead
of CommonJS.
Parenthesize as `(options.target ?? ts.ScriptTarget.ES5) >= ts.ScriptTarget.ES2015`
so the default is applied before the comparison, and use the enum rather than the
literal `2` for intent.
Scope: this is an internal-correctness fix to the helper. Its only caller in
Runtime spreads `fixedCompilerOptions` (target: ESNext) before calling it, so the
plugin itself never reaches the ES5 branch and behaviour is unchanged today; the
fix makes the helper correct if reused, or if that call path ever changes.
Adds three setModuleResolution cases, appended to the existing utils suite.1 parent 03782b7 commit 8841cd8
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
492 | 494 | | |
493 | 495 | | |
494 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
0 commit comments