Skip to content

Support TypeScript 6 - #22

Merged
0x80 merged 1 commit into
mainfrom
thijs/0217-support-typescript-6
Feb 17, 2026
Merged

Support TypeScript 6#22
0x80 merged 1 commit into
mainfrom
thijs/0217-support-typescript-6

Conversation

@0x80

@0x80 0x80 commented Feb 17, 2026

Copy link
Copy Markdown
Owner

TypeScript 6 changed how conditional types resolve when a generic parameter defaults to undefined. The SelectedDocument type caused S[number] to evaluate to unknown when S defaults to undefined, producing Pick<T, unknown> (an empty type) instead of T. This broke all call sites using getDocuments, getFirstDocument, processDocuments, etc. without an explicit select option.

The fix reverses the conditional check order to test for undefined first, so the default case resolves correctly before TypeScript 6 can misresolve the array branch.

Also upgrades the typescript devDependency to 6.0.0-beta.

TypeScript 6 changed how conditional types resolve when a generic
parameter defaults to undefined. The SelectedDocument type now checks
for undefined first, preventing S[number] from evaluating to unknown
when S defaults to undefined.

Also upgrades typescript devDependency to 6.0.0-beta.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the SelectedDocument conditional type to behave correctly under TypeScript 6’s updated conditional type resolution (specifically when the generic S defaults to undefined), preventing Pick<T, unknown>-style breakages across collection helpers. Also updates the repository’s TypeScript devDependency to TS 6 beta to validate the fix in CI/tooling.

Changes:

  • Reorders the SelectedDocument<T, S> conditional checks to handle undefined first, restoring the default-to-T behavior under TS6.
  • Bumps the typescript devDependency to 6.0.0-beta.
  • Updates pnpm-lock.yaml to reflect the TypeScript upgrade and dependent peer resolution.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/collections/types.ts Fixes SelectedDocument conditional typing for TS6 when S defaults to undefined.
package.json Upgrades TypeScript devDependency to 6.0.0-beta.
pnpm-lock.yaml Locks the TypeScript upgrade and updates dependent snapshot entries.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@0x80
0x80 merged commit 08ef999 into main Feb 17, 2026
11 checks passed
0x80 added a commit that referenced this pull request Feb 17, 2026
Adds a compile-time type test file for the `SelectedDocument`
conditional type, verified by `pnpm check-types` (tsc --noEmit). This
locks in the behavior fixed in #22 for TypeScript 6 compatibility.

Tests verify:
- Default/undefined `S` resolves to the full type `T`
- Key array `S` resolves to `Pick<T, ...>`
- Invalid keys are rejected
- Correct resolution through defaulted generic parameters (as used in
`getDocuments`)

The test file is not imported by any source module, so it does not
appear in build output. Type test files are excluded from linting since
the type aliases are intentionally unused at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants