Skip to content

Commit b565bed

Browse files
authored
fix(lint): fix false negative in noMisleadingReturnType for union annotations (#10052)
1 parent 9b027a6 commit b565bed

6 files changed

Lines changed: 886 additions & 97 deletions

File tree

.changeset/lazy-days-know.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Improved [`noMisleadingReturnType`](https://biomejs.dev/linter/rules/no-misleading-return-type/): it now flags union annotations whose extra variants are never returned, and suggests the narrower type (e.g. `string | null``string`).
6+
7+
These functions are now reported because `null` and `number` are included in the return annotations but never returned:
8+
9+
```ts
10+
function getUser(): string | null { return "hello"; } // null is never returned
11+
function getCode(): string | number { return "hello"; } // number is never returned
12+
```

0 commit comments

Comments
 (0)