Repository navigation
docs(oracles): require typechecking oracle files across skills #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,24 @@ suite (thousands of tests). Run it again with | |
| `NODE_OPTIONS=--max-old-space-size=8192`, or with `--contexts 2`. Keep | ||
| every test and history: do not shrink the oracle to make it fit. | ||
|
|
||
| **TypeScript reports untyped imports (`TS7016` / `TS7006`) on `.js` or `.mjs` | ||
| production files.** Import through the package's typed entry where one | ||
| exists instead of an untyped relative `.js` or `.mjs` path. When no typed | ||
| entry covers the module, enable `allowJs` in the test or oracle tsconfig | ||
| instead of hiding errors with `any` or `@ts-ignore`. | ||
|
|
||
| **TypeScript rejects `constructed[].build` on a union literal or tuple.** | ||
| Inside an unannotated `oracleProperty(...)` call, TypeScript can widen union | ||
| string literals or fixed-length tuples returned by `build`. Give `build` an | ||
| explicit return type (`build: (generated): History => ({ ... })`) or narrow | ||
| the literal with `as const`. | ||
|
|
||
| **The repository's `tsconfig.json` does not cover the oracle file.** Vitest | ||
| strips types without checking them, so an excluded oracle file can pass | ||
| `oracle-gaps` while failing `tsc --noEmit`. When the repository uses | ||
| TypeScript 5 or newer, check that the oracle file typechecks under the | ||
| repository's `tsc --noEmit` (or a test tsconfig that extends `tsconfig.json`). | ||
|
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the excluded oracle in the typecheck. If the repository tsconfig excludes the oracle,
|
||
|
|
||
| ## Probes | ||
|
|
||
| **The tests import a build that is not built yet.** Import the source that | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,12 @@ search is your main job. | |
| Require a history step that simulates the contradictory signal. | ||
| Expect production to fail at the boundary, before it releases established | ||
| state or publishes success. | ||
| - **Unchecked TypeScript in oracle files.** Vitest strips types without | ||
| checking them, so a passing gap check does not prove that oracle `.ts` | ||
| files typecheck. When the repository uses TypeScript 5 or newer, check | ||
| that its `tsconfig.json` (or test/oracle tsconfig) covers the oracle files | ||
| and that `tsc --noEmit` passes without `@ts-ignore` or `@ts-expect-error` | ||
|
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run the configuration that covers the oracle files. If
|
||
| hiding type errors. | ||
|
Comment on lines
+112
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check for file-wide type suppression. An oracle with
|
||
|
|
||
| ## 4. Choose challenges for the real uncertainty | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,22 @@ If the repository's own lint or formatter covers the oracle files (for | |
| example, an older ESLint with Prettier over `test/`), keep the oracle files | ||
| out of its globs, or match its style. Say which in your report. | ||
|
|
||
| **Typecheck.** Vitest strips TypeScript types without checking them, so a | ||
| passing oracle run does not prove that the oracle files typecheck. When the | ||
| repository uses TypeScript 5 or newer: | ||
|
|
||
| - Verify that its `tsconfig.json` (or its test tsconfig) includes the oracle | ||
| files, and run its typecheck (for example `tsc --noEmit`). If the main | ||
| `tsconfig.json` excludes tests, add the oracle glob to the test tsconfig | ||
| or add a small `tsconfig.oracles.json` that extends it. | ||
|
Comment on lines
+160
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Select the oracle tsconfig in the typecheck command. If the root config excludes tests and the developer adds Show
|
||
| - When production files are `.js` or `.mjs` without matching `.d.ts` files, | ||
| import through the package's typed entry where one exists, or enable | ||
| `allowJs` in the test or oracle tsconfig so TypeScript does not reject | ||
|
Comment on lines
+164
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep oracle imports on the current production source. If an oracle imports the package through its typed entry, and that entry resolves to build output such as The guidance must require that oracles and
|
||
| untyped relative imports. | ||
| - When the repository uses TypeScript older than 5, or none, keep the oracle | ||
| files out of its `tsc` run (step 2) and do not add a typecheck that uses | ||
| the gap check's own `tsc`. | ||
|
|
||
| **Lint.** Add both presets to the ESLint flat config: | ||
|
|
||
| ```js | ||
|
|
@@ -322,15 +338,18 @@ optimization project. | |
| full. | ||
| - Lint each oracle file and each changed production file after you edit it. | ||
| Fix every report. Do not disable a rule. | ||
| - Typecheck each oracle file after you edit it (Vitest strips types without | ||
| checking them). | ||
| - Oracle files: `<oracle file glob>`. Gap check: `<gap check command>`. | ||
|
|
||
| <!-- END @tanstack/oracles --> | ||
| ``` | ||
|
|
||
| If lint is an environment limit (step 3), replace the lint line with "Lint: | ||
| not available here (<the reason>)." Fill in the two placeholders in step 7, | ||
| once their values exist. A run that stops before step 7 leaves them in | ||
| place, and its report says so. | ||
| not available here (<the reason>)." If the repository does not use | ||
| TypeScript 5 or newer, omit the typecheck line. Fill in the two placeholders | ||
| in step 7, once their values exist. A run that stops before step 7 leaves | ||
| them in place, and its report says so. | ||
|
|
||
| In a workspace with a package-local install, put the block in the package's | ||
| instruction file, where its `node_modules` paths resolve. A root copy must | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give callback parameters explicit types when
allowJscannot infer them.allowJslets TypeScript read untyped.jsor.mjsfiles. It does not add types that the JavaScript source does not declare. A TypeScript callback passed to such a function can still fail with TS7006 (Parameter 'x' implicitly has an 'any' type). Annotate the callback parameter in the TypeScript code, or add a JSDoc type or declaration for the JavaScript function.