Repository navigation
Conversation
|
YLfjuk
commented
Oct 20, 2026
|
|
||
| Each package's `tsconfig.test.json` includes its source and existing `.spec.ts` tests. Both `test:types` and Vitest use it, so `test`, `test:v`, and `coverage` check type assertions too. The source-only `tsconfig.json` files remain separate for package builds. | ||
|
|
||
| `pnpm run test:discovery` temporarily adds an invalid `expectTypeOf` assertion to each package and verifies that both the package compiler command and root Vitest command report it. Its `finally` block attempts to remove every temporary file on success or a handled failure. Forced termination or filesystem errors can leave files behind. Before rerunning tests, manually delete any `*-typecheck-discovery-*.spec.ts` files in `packages/types/__tests__`, `packages/utils/__tests__`, and `packages/core/tests`. These generated files are ignored by Git. |
YLfjuk
commented
Oct 20, 2026
| type Actual = LastOfUnion<Members>; | ||
|
|
||
| expectTypeOf<Actual>().toEqualTypeOf<Expected>(); | ||
| // Union ordering is not guaranteed by TypeScript. |
Owner
Author
There was a problem hiding this comment.
then this type is kind of useless
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.
Existing
.spec.tsfiles ran as JavaScript, but theirexpectTypeOfassertions were not compiled: Vitest's default typecheck discovery selects declaration-style type tests, and each package tsconfig includes onlysrc.This change adds a no-emit test tsconfig per package and uses it for both
test:typesand explicit per-project Vitest typecheck discovery. Normaltest,test:v, andcoveragecommands now compile the existing assertions in types, utils, and core. Source-only build configs remain unchanged. Vitest 4.1.11 invokes the TypeScript 7.0.2 CLI successfully once discovery and compiler input files are configured; no dependency or build-pipeline migration is needed.UnionToTuple assertions check the complete member union and exact tuple length, plus empty/singleton cases. LastOfUnion assertions check that the result is a non-never member, is not a union of multiple disjoint literals, and preserves singleton/empty cases. Neither test assumes compiler-specific union ordering. No type implementations changed. The public UnionToTuple JSDoc correction belongs to CORE-04 in #17; clarifying LastOfUnion's compiler-dependent “last” wording is a separate documentation follow-up.
A small
test:discoveryguard runs before typechecking in CI. It creates an incorrectexpectTypeOf<number>().toEqualTypeOf<string>()assertion in each existing test directory and requires both the package compiler command and root Vitest command to diagnose that exact file. It detects missing discovery even when another genuine test already fails.The guard checks
npm_execpathbefore creating fixtures and gives an actionable invocation error when it is missing. JavaScript CLI paths run through Node; native executables run directly without a shell. Cleanup attempts every owned fixture, reports filesystem errors, and exits unsuccessfully if any removal fails. Forced termination can leave invalid specs behind: three narrow Git ignore patterns prevent accidental staging of generated fixtures. No signal/process framework was added.Validation on Windows, Node 24.19.0 / pnpm 11.22.0:
pnpm run fmt:check;pnpm run lintwith 10 existing warnings;git diff --check.pnpm run test:discovery. All three compiler commands reject the deliberate assertion with TS2344; root Vitest rejects all three with TypeCheckError. No generated sentinel files remain.@pnpm/exedistribution, downloaded only under ignored local artifacts. No global installation or configuration changed. Other native platforms were not tested. This is a portability fix, not a demonstrated current CI failure: pnpm/action-setup defaults standalone to false for pnpm 11.npm_execpathfails with the invocation guidance and leaves no fixtures.test:types; source-onlytsc -p tsconfig.json --noEmitin all three packages.pnpm run build --force, all three tasks uncached, including types runtime/type tests, publint, and attw. Existing experimental/no-output/profile warnings remain.test:types, rootpnpm run test:types, rootpnpm run test, andpnpm run coverage, due only topackages/utils/__tests__/enum/to-tuple.spec.ts:18, TS2344 / TypeCheckError. Coverage reports 129 passing file entries, one failed typecheck file, 657 passing tests, one failed assertion, and nine todo. Runtime and typecheck entries are both counted.Blocked draft: CORE-04 in #17 must resolve Enum.toTuple/enumToTuple's false ordering contract before normal checks can pass honestly. Its assertion is unchanged. This PR does not remove that API, exclude tests, weaken real assertions, or add suppression directives. CORE-04 was not merged or rebased into this branch.
Earlier optional exact-property diagnostics remain outside this revision: PickOptional is CORE-09; PatchUnion expectations need coordination; the exact-mode matrix is CORE-18. The default compiler mode is preserved. CORE-02 audit work was not changed or re-audited.
Tooling/tests/docs only: no consumer-facing package change, version bump, or changeset. No review comments, merge, approval, publication, deployment, or watchers.
README-only follow-up: removed the discovery guard implementation and recovery paragraph at the reviewer's request. The development command list, test tsconfig explanation, and discovery guard behavior remain.
pnpm run fmt:checkandgit diff --checkpass for this follow-up; the full test suite was not rerun.