Repository navigation
fix(postgrest-typegen): compile under noUncheckedIndexedAccess - #217
Conversation
The Supabase CLI type-checks its dependencies from source: its tsconfig extends @tsconfig/bun and sets customConditions: ["bun"], so tsc follows this package's bun exports condition to src/*.ts. Those files failed the CLI's noUncheckedIndexedAccess flag with 85 errors, which forced the CLI to keep a direct dependency on @supabase/postgrest-typegen pinned to dist/index.d.ts instead of depending on @supabase/typegen alone. Enable noUncheckedIndexedAccess in this package and fix every site it flags in the four generators, without changing output: indexed lookups now go through optional chaining, a checked local, or a helper that throws when an entry that must exist by construction is missing. Inline snapshots and the parity goldens are unchanged. Add tsconfig.consumer.json, which extends @tsconfig/bun with customConditions: ["bun"], and run it as check-types:consumer in CI so a future change cannot reintroduce an unchecked indexed access. Refs SDK-1963
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (12)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe package enables Priority: ➖ Normal Change: Refactor Merge Risk: ⚪ Minimal · up to The stricter type checks and generator changes have no established merge-blocking issue; proceed with normal validation. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 I have created a release *beep* *boop* --- ## [0.2.5](postgrest-typegen/v0.2.4...postgrest-typegen/v0.2.5) (2026-09-25) ### Bug Fixes * **postgrest-typegen:** compile under noUncheckedIndexedAccess ([#217](#217)) ([a8a4927](a8a4927)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
## Why postgrest-typegen 0.2.5 (#217, released in #220) is the first version whose `src/` compiles under `noUncheckedIndexedAccess`. The Supabase CLI type-checks its dependencies from source through the `bun` exports condition, so with this pin the CLI can depend on `@supabase/typegen` alone and drop its direct, `dist`-pinned `@supabase/postgrest-typegen` dependency. Second part of [SDK-1963](https://linear.app/supabase/issue/SDK-1963); the first part was #217. ## What - Pin `@supabase/postgrest-typegen` to `0.2.5` and update `bun.lock`. - Add the consumer type-check that #217 deliberately left out of this package because it could not pass against 0.2.4: `tsconfig.consumer.json` extends `@tsconfig/bun` with `customConditions: ["bun"]` and includes `src`, wired up as `bun run check-types:consumer` and run in `typegen-validate.yml`. Because it resolves `@supabase/postgrest-typegen` to the pinned package's `src/`, it fails on a future pin bump whose source breaks under the CLI's compiler options. - Add `@tsconfig/bun` as a devDependency and document the command in `CLAUDE.md` and `README.md`. ## Verification - `bun run check-types`, `bun run check-types:consumer`, `bun run format-and-lint`, `bun run knip`, `bun run build` pass. - `bun run test`: 47 tests pass. - Against the previous pin (0.2.4) the consumer check fails with 85 errors in `node_modules/@supabase/postgrest-typegen/src/generation/*.ts`, so the check is exercising the transitive source as intended. ## Follow-up Once the typegen release cut from this PR is on npm, the CLI can bump `@supabase/typegen` and remove the direct `@supabase/postgrest-typegen` devDependency, its `minimumReleaseAgeExclude` entry, the `paths` pin in `apps/cli/tsconfig.types.json`, the `knip.jsonc` `ignoreDependencies` entry, and the version-guard test in `types.generator.unit.test.ts` (follow-up to supabase/cli#6822).
…en command comments (#223) Documentation-only follow-up to #217 and #222. No code, workflow, or configuration changes. ## What changed - Root `CLAUDE.md`: the release notes for `release-typegen.yml` and `release-postgrest-typegen.yml` now spell out what on-demand means. release-please runs only on a manual `workflow_dispatch`, or on a push that changes the package's manifest file, which happens only when a release PR merges. Merging ordinary `fix:` or `feat:` commits into `packages/typegen` or `packages/postgrest-typegen` opens no release PR until someone dispatches the workflow. - `packages/postgrest-typegen/CLAUDE.md`: re-align the comment column in the Commands block. The `check-types:consumer` line added in #217 is longer than the others, so every comment now starts at the same column after it. ## Why After #222 merged, no typegen release workflow run fired and no release PR appeared. That was expected behavior from the manifest path filter, but it was not obvious from the docs, so this records it. The typegen release carrying the postgrest-typegen 0.2.5 pin is therefore waiting on a manual dispatch. ## Notes for reviewers This PR originally also passed `skip-github-pull-request` on push runs of `release-typegen.yml`. That change was dropped because the existing path filter already gives the described behavior, and it kept the two release workflows identical apart from the package name.
Why
The Supabase CLI type-checks its dependencies from source:
apps/cli/tsconfig.jsonextends@tsconfig/bunand setscustomConditions: ["bun"], sotscfollows this package'sbunexports condition tosrc/*.tsinstead ofdist/*.d.ts. Those files failed the CLI'snoUncheckedIndexedAccessflag with 85 errors (TS2532,TS18048,TS2345,TS2322, plusanycascades), which is why the CLI still declares@supabase/postgrest-typegendirectly and pins it todist/index.d.tsthroughtsconfig.types.json. Every postgrest-typegen release therefore meant bumping two CLI dependencies in lockstep, which the@supabase/typegenregistry was meant to remove.Fixes SDK-1963.
What
noUncheckedIndexedAccessintsconfig.jsonandtsconfig.build.json.src/generation/{typescript,python,go,swift}.tswithout changing output:array[0]behind alength === 1orlength > 0check becomes a checked local (soleInArg,conflictingFn,enumType).key in recordfollowed byrecord[key].push(...)becomesrecord[key]?.push(...).acc[key] ??= []; acc[key].push(x)becomes(acc[key] ??= []).push(x).for (const key in record) record[key].sort(...)iteratesObject.values(record)instead.columnsByTableId[table.id],introspectionBySchema[schema.name], Python'sthis.schemas[name]) go through small helpers that throw a descriptive error instead of!assertions. Previously a miss would have been aTypeErroronundefined.word[0].toUpperCase()insideif (word)becomesword.charAt(0).inArgs[0]!inisComputedFieldOfis replaced by the same checked-local pattern.tsconfig.consumer.json, which extends@tsconfig/bunwithcustomConditions: ["bun"]and includessrc, wired up asbun run check-types:consumerand run inpostgrest-typegen-validate.yml. This mirrors the CLI's compiler options so a regression fails here first.@tsconfig/bunas a devDependency and document the new command in the packageCLAUDE.md.Verification
bun run check-types,bun run check-types:consumer,bun run format-and-lint,bun run knip,bun run buildall pass.bun run test: 140 tests pass, 37 inline snapshots unchanged,test/parity/expected/*unchanged. Output is byte-identical.test/sort.test.ts,test/validation/validate.test.ts) only adapt to the flag; no assertions changed.Follow-ups
packages/typegenshould get the same consumer check, but it pins the published@supabase/[email protected], whosesrc/still fails under these flags. Adding it now would be red, so it belongs in the pull request that bumps the pin to the release cut from this change.@supabase/postgrest-typegendevDependency, itsminimumReleaseAgeExcludeentry, thepathspin intsconfig.types.json, theknip.jsoncignoreDependenciesentry, and the version-guard test.