Add compile-time type tests for SelectedDocument - #23
Merged
Conversation
Verify that the conditional type resolves correctly for all cases: default/undefined yields the full type, key arrays yield Pick, and invalid keys are rejected. Also simulates the generic context from getDocuments to ensure proper resolution through defaulted parameters.
There was a problem hiding this comment.
Pull request overview
Adds compile-time TypeScript “type tests” to lock in the expected behavior of the SelectedDocument conditional type (including the TypeScript 6 default-generic fix from #22), validated via pnpm check-types (tsc --noEmit).
Changes:
- Introduces a dedicated type-test file validating
SelectedDocument<T, S>resolution for default/undefined, key-array selection, and invalid key rejection. - Adds coverage for the “defaulted generic parameter flows through” scenario (mirroring
getDocuments-style generics).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Adds a compile-time type test file for the
SelectedDocumentconditional type, verified bypnpm check-types(tsc --noEmit). This locks in the behavior fixed in #22 for TypeScript 6 compatibility.Tests verify:
Sresolves to the full typeTSresolves toPick<T, ...>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.