Skip to content

Add compile-time type tests for SelectedDocument - #23

Merged
0x80 merged 2 commits into
mainfrom
thijs/0217-add-ts-tests
Feb 17, 2026
Merged

Add compile-time type tests for SelectedDocument#23
0x80 merged 2 commits into
mainfrom
thijs/0217-add-ts-tests

Conversation

@0x80

@0x80 0x80 commented Feb 17, 2026

Copy link
Copy Markdown
Owner

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.

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.

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

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.

@0x80
0x80 merged commit 7e2c3a8 into main Feb 17, 2026
5 checks passed
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