Repository navigation
fix(cli): give the objectui init scaffold the vite-env.d.ts its own build script needs (#4111) - #4120
Merged
Merged
Conversation
… build needs (#4111) The scaffold `objectui init` writes declares `build: "tsc && vite build"`, so unlike the two temp-app generators objectui#3853 fixed, its tsconfig is not decorative: tsc runs first, on the way to a production build. Its `src/main.tsx` did `import './index.css'` with no ambient declaration behind it, so a user who followed the generated README — `objectui init`, then `npm run build` — met TS2882 in a file the tool had just written, before Vite was ever reached. Fixed at the template, the same way and with the same bytes as the sibling generators: the scaffold now writes `src/vite-env.d.ts` carrying the `vite/client` triple-slash reference, where the `declare module '*.css'` declarations live. `vite` was already in SCAFFOLD_DEV_DEPENDENCIES. Measured, not assumed: generating the scaffold to disk and running the workspace tsc with its own tsconfig found that one error and none of objectui#3853's other four classes — no unused import, no implicit any, no required-prop call site. Those live in a `src/Layout.tsx` this scaffold does not have. Measured a second time with `@object-ui/react`/`@object-ui/components` mapped onto their in-repo source via tsconfig `paths`, so the diagnostics the unresolved-module exemption would hide became visible: all three templates clean apart from the `./index.css` TS2882. The objectui#3853 tsc gate now covers the third generator, with the reverse verification (delete the file, TS2882 for './index.css' and nothing else) as an in-suite self-test, and pins the two premises that test rests on: that the scaffold's build script really runs tsc, and that its three templates share one `src/**` tree so one tsc run judges all three. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Fixes #4111
commands/init.tsis the CLI's third app generator, with its owntsconfigobject, and it was outside the surface of #4113 (#3853). Unlike the two temp-app generators that PR fixed, this one's tsconfig is not decorative: thepackage.jsonthe scaffold writes declaresso
tscruns first, on the way to a production build. A user who runsobjectui initand then thenpm run buildthe generated README names hits a type error in a file the tool wrote for them, before Vite is ever reached.Ordering
PR #4113 had merged by the time this work started (
origin/main@9b9fa4961), so this branches offmainnormally — no stacking, and the gate this extends is already there.Premise check — reproduced on the tip this branches from
Generated
buildInitFiles('sample-app', 'simple')to disk and ran the workspace'stsc -pwith the scaffold's owntsconfig.json:The issue's line and column hold verbatim. The two
@object-ui/*diagnostics are the probe not installing them, which is the exemption #4113 already defines and bounds.Measured, not assumed: this scaffold has ONE of the five error classes, not seventeen
The card asked for a full run rather than the targeted probe the issue was filed from. Measured twice, and both say the same thing.
1. As the gate sees it. No unused import (TS6133/TS6196), no implicit any (TS7031/TS7006), no required-prop call site (TS2741). That is not luck: sixteen of #4113's seventeen live in
src/Layout.tsxand the routedsrc/App.tsx, and this scaffold has neither — its wholesrc/**is a 9-linemain.tsx, a 4-lineApp.tsxand a stylesheet.2. With the exempt modules resolved, so the exemption hides nothing. The one thing a bare-specifier exemption can conceal here is the call site
SchemaRenderer schema={schema}: with@object-ui/reactunresolved that component isany, so theapp.jsoneach template inlines is checked against nothing. Mapped@object-ui/reactand@object-ui/componentsonto their in-repo source via tsconfigpaths— real prop types, realresolveJsonModuleinference — and ran all three templates:src/main.tsx(4,8): TS2882 './index.css'src/main.tsx(4,8): TS2882 './index.css'src/main.tsx(4,8): TS2882 './index.css'So the one error is the whole defect, the three templates agree, and the
schemaprop is genuinely clean against the library's real type rather than merely unchecked.The fix
buildInitFilesnow writessrc/vite-env.d.tsholding thevite/clienttriple-slash reference — the filecreate-vite's own React+TS template writes for exactly this reason, and where thedeclare moduleambient declarations for stylesheets live.viteis already inSCAFFOLD_DEV_DEPENDENCIES, so nothing new is declared.Its bytes are identical to
APP_VITE_ENV_D_TSinutils/app-generator.ts. I deliberately did not export that constant and import it across:commands/init.tswould then depend on the temp-app generator module (pullingjs-yamlinto theinitcommand's load path) to share a 40-character ecosystem-standard string. Instead the three copies are pinned to one literal by the reachability test below, which is the same backstopDEPENDENCY_ANCHORSgives the ranges — drift fails a test instead of shipping. Happy to switch to a shared constant if a reviewer prefers the coupling.The gate
Four additions to the #4113
tscblock, all judging the artifact rather than this repo's source text:type-checks the init scaffold, whose own build script really runs tsc— a realtsc -pover the scaffold written to disk, through the sameexpectCleanTypeCheck/ bare-vs-relative exemption the other two use. Generated under the repo's.objectui-tmp/for the module-resolution reason fix(cli): make the generated temp app pass its own strict tsconfig, and gate it with real tsc (#3853) #4113 records.pins that the init scaffold is the generator whose build really runs tsc— the premise that makes this one live rather than latent. If that script ever stops runningtsc, a reader of the gate above needs to know.writes one src tree for all three templates, so one tsc run judges them all— whysimplealone is gated rather than paying ~1s three times: the templates differ inapp.jsonand in nothing else, asserted file by file, plus a non-vacuity check that the threeapp.jsonreally are three.goes red on the pre-fix init scaffold, with the defect the issue measured— the in-suite self-test.The reachability test
exempts the ambient declaration, and nothing else, from reachabilitynow loops over the init map too, which is what pins the three generators to one string.init()writes withfsdirectly and derives its target fromprocess.cwd(), so the gate writes the file map — sound becausecli-bin.test.tsalready pinsinit()againstbuildInitFilesbyte for byte through the real bin. That equivalence is cited in the new helper's comment.Reverse verification — direction predicted first, then run
Predicted: reverting
init.tsturns the new tsc gate red withTS2882naming'./index.css'and nothing else; the ambient-exemption test red on the file being absent; and the new self-test's own "nothing to revert" tripwire fires, since deleting a file it has already deleted is a no-op. Reverted withgit checkout origin/main -- packages/cli/src/commands/init.ts(nevergit stash— shared stack), and measured:Three for three, including the tripwire. Restored, green again.
The self-test pins exactly
{ TS2882: 1 }and then asserts the specifier and the file, because@object-ui/componentsis a TS2882 as well — a gate that counted codes alone could not tell the exempt one from the defect.Verification
vitest run packages/cli/from the repo root: 105 passed (4 files), 22.6s (was 101 after fix(cli): make the generated temp app pass its own strict tsconfig, and gate it with real tsc (#3853) #4113 — the four new cases).pnpm --filter @object-ui/cli type-check: exit 0.pnpm --filter @object-ui/cli lint: 0 errors, 15 warnings — the same 15 fix(cli): make the generated temp app pass its own strict tsconfig, and gate it with real tsc (#3853) #4113 reported, all pre-existing on untouched lines, none in either file this PR edits.pnpm changeset:check: fixed group and no-major both green.pnpm check:control-bytes: OK (3970 files).Changeset:
patchon@object-ui/cli— the scaffold's template source ships inside the released package.Out of scope
Nothing new filed. Everything measured here is either fixed above or already recorded on #4111 / #4113.
Generated by Claude Code