Skip to content

Commit d83c66b

Browse files
authored
chore(xtask): migrate Error global type (#10721)
1 parent 2862780 commit d83c66b

27 files changed

Lines changed: 2966 additions & 285 deletions

.changeset/huge-parrots-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Improved type-aware lint rule inference for built-in globals and indexed function calls. Biome now resolves `Error(...)`, `new Error(...)`, optional `Error#stack`, and calls through indexed function values such as `handlers[0]()` more accurately.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const handlers: Array<() => Promise<void>> = [() => Promise.resolve()];
2+
3+
handlers[0]();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
source: crates/biome_js_analyze/tests/spec_tests.rs
3+
expression: indexedFunctionCall.ts
4+
---
5+
# Input
6+
```ts
7+
const handlers: Array<() => Promise<void>> = [() => Promise.resolve()];
8+
9+
handlers[0]();
10+
11+
```
12+
13+
# Diagnostics
14+
```
15+
indexedFunctionCall.ts:3:1 lint/nursery/noFloatingPromises ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
16+
17+
i A "floating" Promise was found, meaning it is not properly handled and could lead to ignored errors or unexpected behavior.
18+
19+
1 │ const handlers: Array<() => Promise<void>> = [() => Promise.resolve()];
20+
2 │
21+
> 3 │ handlers[0]();
22+
│ ^^^^^^^^^^^^^^
23+
4 │
24+
25+
i This happens when a Promise is not awaited, lacks a `.catch` or `.then` rejection handler, or is not explicitly ignored using the `void` operator.
26+
27+
i This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
28+
29+
30+
```

crates/biome_js_type_info/src/flattening.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl TypeData {
8484
},
8585
None => None,
8686
},
87-
Self::TypeofExpression(expr) => flattened_expression(expr, resolver, 0),
87+
Self::TypeofExpression(expr) => flattened_expression(expr, resolver),
8888
Self::TypeofType(reference) => resolver
8989
.resolve_reference(reference.as_ref())
9090
.map(Self::reference),

0 commit comments

Comments
 (0)