Support TypeScript 6 - #22
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
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 handleundefinedfirst, restoring the default-to-Tbehavior under TS6. - Bumps the
typescriptdevDependency to6.0.0-beta. - Updates
pnpm-lock.yamlto 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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypeScript 6 changed how conditional types resolve when a generic parameter defaults to
undefined. TheSelectedDocumenttype causedS[number]to evaluate tounknownwhenSdefaults toundefined, producingPick<T, unknown>(an empty type) instead ofT. This broke all call sites usinggetDocuments,getFirstDocument,processDocuments, etc. without an explicitselectoption.The fix reverses the conditional check order to test for
undefinedfirst, so the default case resolves correctly before TypeScript 6 can misresolve the array branch.Also upgrades the typescript devDependency to 6.0.0-beta.