Repository navigation
feat(cli): on TypeScript 7, read types with its TypeScript 6 API package, and name the remedy - #7721
Conversation
When the project's TypeScript is missing, older than a check reads, or has no JavaScript compiler API (TypeScript 7), the skip reason of the doc-type and prop checks now names the version and what to do: install TypeScript 5.0 through 6 (`npm install -D typescript@6`). `integration check --strict` fails with that message.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 482 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This looks good to merge: every TypeScript skip reason in integration check and in doctor integration validate and components now ends with a remedy that works, while the exit codes, skip codes and JSON shape stay the same. On a freshly scaffolded integration with TypeScript 7.0.2, following the new message (npm install -D typescript@6) makes integration check --strict pass with nothing skipped. One optional polish: the Changeset says the reasons "now name the version" and that --strict fails "instead of a bare skip", but the version was already named and --strict already failed with the reason, so only the remedy is new.
[Automated review]
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] When the project's TypeScript is missing, too old, or has no JavaScript compiler API (TypeScript 7), `integration check` and `doctor integration validate|components` now name the version and the fix in the skip reason: install TypeScript 5.0 through 6 (`npm install -D typescript@6`). `--strict` fails with that message instead of a bare skip. |
There was a problem hiding this comment.
Optional wording: before this change the no-API and too-old reasons already named the installed version, and --strict already failed with the reason, so only the fix is new. For example: "... now end the skip reason with the fix: install TypeScript 5.0 through 6 (npm install -D typescript@6). --strict fails with the same message."
TypeScript 7 ships no JavaScript compiler API; TypeScript publishes `@typescript/typescript6` for tools that need one. Where the project's `typescript` has no `createProgram`, the checks now use that package when it is installed, and the remedy names it first.
1b42268 to
6680658
Compare
There was a problem hiding this comment.
Changes requested: the @typescript/typescript6 fallback works, and a TypeScript 7 package that installs it now passes integration check --strict with both comparisons run, but the docs still describe the old rule. Please update the help and guides that say the checks read only the project's own typescript (the doctor integration components and validate command docs, the integrationComponentConflicts and validateIntegration API docs, and the check-the-props, check-your-docs and checks guides), and the quick start, which tells TypeScript 7 users the checks skip (quick-start.doc.mjs:52), since automatic CLI behavior must be documented and discoverable (AST-017 FR14). Describe the condition the code implements, which also covers a folder with no typescript installed; no code change is needed.
[Automated review]
| // TypeScript 7 has no JavaScript compiler API; the package TypeScript | ||
| // ships beside it for tools that need one carries TypeScript 6's. | ||
| try { | ||
| const ts = require(TYPESCRIPT_6_API); | ||
| if (ts && typeof ts.createProgram === 'function') { | ||
| return {ts, version: String(ts.version)}; | ||
| } | ||
| } catch { | ||
| // Not installed from here; try the next directory. | ||
| } |
There was a problem hiding this comment.
This fallback is automatic CLI behavior, so AST-017 FR14 needs it documented and discoverable, but the help and guides still say the checks read the project's own typescript (doctor-integration-components.doc.mjs, doctor-integration-validate.doc.mjs, integrationComponentConflicts.doc.mjs, validateIntegration.doc.mjs, check-the-props.doc.mjs, check-your-docs.doc.mjs, checks.doc.mjs), and quick-start.doc.mjs:52 says TypeScript 7 makes the checks skip. Please describe it there.
This require also runs when no typescript resolves from the folder (the catch above falls through to it), so a package with only @typescript/typescript6 is checked with it too; the docs should say so.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [feat] On TypeScript 7, which ships no JavaScript compiler API, the doc-type and prop checks in `integration check` and `doctor integration validate|components` use the TypeScript 6 API package TypeScript publishes for tools (`@typescript/typescript6`) when the project installs it beside TypeScript 7. When no usable TypeScript is found, the skip reason now ends with the remedy: add `@typescript/typescript6` on TypeScript 7, or install TypeScript 5.0 through 6 (`npm install -D typescript@6`). |
There was a problem hiding this comment.
The fallback also applies where no typescript is installed at all, not only beside TypeScript 7: a package with only @typescript/typescript6 now runs both comparisons and passes --strict. Saying so here keeps the release note in line with the code.
…ypescript cannot be used The command docs, API docs, check guides and quick start now say the doc-type and prop checks use the project's `@typescript/typescript6` where its own `typescript` is missing or has no JavaScript compiler API (TypeScript 7).
There was a problem hiding this comment.
Looks good to merge: with @typescript/typescript6 installed beside TypeScript 7, integration check --strict now runs both the doc-type and prop comparisons (through TypeScript 6.0.3), and every TypeScript skip reason ends with a remedy that works. The help, API docs and guides now describe the fallback, including a folder with no typescript, and the exit codes, skip codes and JSON shape are unchanged. Nothing further is needed from you.
[Automated review]
User impact
TypeScript 7 is npm's
latest, and it ships no JavaScript compiler API (createProgram). In a project on TypeScript 7,integration checkskips the doc-type and prop comparisons, and--strictthen fails with "TypeScript 7.0.2 is installed in this project, but it has no JavaScript compiler API (createProgram) to read types with, so docs were not checked.". That names the problem but not what to do. The skip reasons for a missing or too-old TypeScript ended with "Install typescript" or "Upgrade typescript", and today that installs TypeScript 7, which fails the same way.Now:
@typescript/typescript6for tools that need a compiler API beside TypeScript 7 (TypeScript 7.1 is expected to bring a new API). When the project'stypescripthas nocreateProgram, the checks use@typescript/typescript6if the project installs it. So a TypeScript 7 project keeps TypeScript 7 fortscand adds one package; it does not downgrade.@typescript/typescript6; otherwise install TypeScript 5.0 through 6 (npm install -D typescript@6). 5.0 is the oldest version that checks a JavaScript doc.--strictfails with that message.Reproduction
A new integration package with
typescript7.0.2 and@typescript/typescript66.0.2 installed from npm, thennpx astryx integration check --strict:Before this change, the same project failed
--strictwith 2 skipped comparisons. With TypeScript 7.0.2 alone :Before this change, the reason ended at "so docs were not checked.".
Fix
resolveProjectTypeScript(foundation/discovery/project-typescript.mjs): where the project'stypescripthas nocreateProgram, it tries@typescript/typescript6from the same folder.TYPESCRIPT_FIX: one sentence used by every skip reason. It covers no TypeScript, a TypeScript with no compiler API, a TypeScript older than the doc-type check reads, and, for prop types, older than 4.8.--strictbehavior are unchanged; only the reason text changes (architecture:cli-surfaceINV33/INV34 already require saying why).Compatibility
Message text only. The JSON shape, exit codes, and skip codes are unchanged.
Testing
@typescript/typescript6that re-exports a real TypeScript: the doc-type check reportschecked, and the prop check compares (anumberdoc againststringcode is atype_mismatch).@typescript/typescript6. These, the new tests, and the too-old cases fail without the change and pass here.vitest run --project node packages/cli/foundation/discovery packages/cli/api/integration/check packages/cli/test/integration-check-failures.test.mjs packages/cli/clients/cli/commands/doctor-integration.test.mjs packages/cli/clients/cli/commands/integration-check.test.mjs: 1,203 pass across doc-compiler, discovery, integration check and test/.tsc -p packages/cli/tsconfig.strict.json, eslint, Prettier,check:changesets, and changeset coverage pass.