Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/quiet-owls-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@biomejs/biome": patch
---

Fixed [#8476](https://github.com/biomejs/biome/issues/8476).
[useAwaitThenable](https://biomejs.dev/linter/rules/use-await-thenable/) no longer reports false positives for `await` on call expressions whose return type cannot be resolved (e.g., cross-module function calls to Node.js builtins or npm packages).
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ await Promise.resolve('value');

const createValue = async () => 'value';
await createValue();

// Cross-module calls whose return type can't be resolved should not
// produce false positives. Biome doesn't parse .d.ts from node_modules,
// so these remain as unresolved TypeofExpression types.
import fs from "node:fs/promises";
await fs.readFile("test.txt", "utf-8");

import { someFunction } from "some-external-package";
await someFunction();
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ await Promise.resolve('value');
const createValue = async () => 'value';
await createValue();

// Cross-module calls whose return type can't be resolved should not
// produce false positives. Biome doesn't parse .d.ts from node_modules,
// so these remain as unresolved TypeofExpression types.
import fs from "node:fs/promises";
await fs.readFile("test.txt", "utf-8");

import { someFunction } from "some-external-package";
await someFunction();

```
8 changes: 6 additions & 2 deletions crates/biome_js_type_info/src/type_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,16 @@ impl TypeData {

/// Returns whether the given type has been inferred.
///
/// A type is considered inferred if it is anything except `Self::Unknown`
/// or an unknown reference, including an unexplicit `unknown` keyword.
/// A type is considered inferred if it is anything except `Self::Unknown`,
/// an unknown reference, or an unresolved typeof expression. Unresolved
/// typeof expressions represent type computations (e.g., return types of
/// cross-module function calls) that could not be flattened, so their
/// actual type is unknown.
pub fn is_inferred(&self) -> bool {
match self {
Self::Reference(TypeReference::Resolved(resolved)) => *resolved != GLOBAL_UNKNOWN_ID,
Self::Unknown => false,
Self::TypeofExpression(_) => false,
_ => true,
}
}
Expand Down