Skip to content

Two noUnsafeOptionalChaining errors block the biome 2.5.x bump (one is in the ui submodule) #510

Closed

Description

@thinkclay

What

@biomejs/biome 2.4.9 → 2.5.5 (dependabot #495) is held back in the dependency batch. 2.5.x promotes lint/correctness/noUnsafeOptionalChaining to an error, and two existing sites trip it.

Measured against identical source:

biome result
2.4.9 (current) 0 errors, 30 warnings
2.5.5 (the bump) 1 error, 30 warnings — per package

So this is two errors total, not a broad cleanup.

The two sites

Both have the same shape: a real runtime guard that a type assertion hides from the linter, so the narrowing never happens.

1. packages/supabase/functions/trpc/routers/profile/completion.router.ts:513

const userTypesArray = Array.isArray(preferencesData?.user_types)
  ? (preferencesData?.user_types as string[]).filter(Boolean)
  : []

Array.isArray(...) does guard it, but as string[] means biome sees (undefined).filter() as reachable. Safe today; the cast is the actual problem. (This file is in the legacy tRPC tree, not the live REST api function.)

2. packages/ui/src/components/ImagePicker/useFilePicker.ts:42 — in the Scaffald/ui submodule

if (typeof (opts?.ref as (el: HTMLInputElement | null) => void) === 'function') {
  ;(opts?.ref as (el: HTMLInputElement | null) => void)(el)
}

Same pattern — typeof … === 'function' guards it, the cast hides that.

Why it is not just fixed inline

Site 2 lives in a submodule, so it needs its own PR against Scaffald/ui plus a pointer bump here — a cross-repo round trip, which is why the bump was deferred rather than forced through while a release was waiting.

To land the bump

  1. Fix site 1 in this repo (hoist to a local const so narrowing survives, drop the cast).
  2. PR site 2 against Scaffald/ui, merge, bump the submodule pointer.
  3. Restore '@biomejs/biome': ~2.5.5 in pnpm-workspace.yaml — the catalog entry currently carries a comment pointing here.

Neither fix is risky; both are strictly better than the cast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions