Skip to content

objectui init scaffold fails its own npm run build: src/main.tsx imports ./index.css with no ambient declaration (TS2882) #4111

Description

@yinlianghui

Out-of-scope finding from objectui#3853 (which fixed the same defect in the other two generators, in app-generator.ts). Filed rather than fixed there: commands/init.ts is a third generator with its own tsconfig object and was outside that card's surface.

Unlike #3853's temp app, this one is live today — the scaffold's own build script runs tsc.

Measured on origin/main @ 877385a76

Generated buildInitFiles('sample-app', 'simple') to disk and ran the workspace's tsc -p with the scaffold's own tsconfig.json. One error is unrelated to module resolution:

src/main.tsx(4,8): error TS2882: Cannot find module or type declarations for
                   side-effect import of './index.css'.

(The other two are @object-ui/react / @object-ui/components not being installed in the probe, which is expected and not a defect.)

Why this one bites, where #3853's did not

#3853's temp app is only ever consumed by Vite, so its tsconfig was decorative. This scaffold's generated package.json declares:

"scripts": {
  "dev": "vite",
  "build": "tsc && vite build",
  "preview": "vite preview"
}

tsc runs first, and the scaffold's tsconfig has strict + noUnusedLocals + noUnusedParameters. So a user who runs objectui init and then the npm run build the README tells them to run gets a type error in a file the tool generated, before Vite is ever reached. That is the follow-the-docs-and-fail shape, on the first command an external user runs.

Cause

buildInitFiles writes src/App.tsx, src/main.tsx and src/index.css, but no ambient declaration for CSS modules. TypeScript has no built-in notion of a .css module; the declarations live in vite/client.

Suggested fix (same shape as #3853's)

Add src/vite-env.d.ts containing the triple-slash reference to vite/client — the file create-vite's own React+TS template writes for exactly this reason. vite is already in the scaffold's devDependencies (SCAFFOLD_DEV_DEPENDENCIES), so nothing new is declared.

Worth pairing it with the tsc gate #3853 added for the other two generators: app-generator.test.ts already builds initFiles() and runs the structural gates over it, so extending the new generated app type-checks under its own tsconfig block to the init scaffold is a small addition, and its .d.ts would need the same reachability exemption that PR already introduced.

Activity

  1. self-assigned this
    on Aug 10, 2026
  2. yinlianghui commented on Aug 10, 2026

    @yinlianghui
    CollaboratorAuthor

    Claim: PM loop round 5 (rolling slot refill; graded up to bug — the defect is LIVE for objectui init users, whose generated build script really runs tsc)
    Session: session_017Qqyix2QcnpUC9XeYVDzx3 · Branch: claude/issue-4111-init-scaffold-tsc · Worktree: objectui-issue-4111
    File surface: packages/cli/src/commands/init.ts (the third generator) + extending the #4113 tsc gate to cover it. Serial constraints: stacks on PR #4113's branch if it has not merged when work starts (same package, same gate file — the dev must check and stack rather than conflict); disjoint from #4106/#3830/#3810/#3788.
    Container & model: S, mode:subagent, model: opus


    Generated by Claude Code

  3. yinlianghui commented on Aug 10, 2026

    @yinlianghui
    CollaboratorAuthor

    ACCEPT (objectui seat PM, session session_017Qqyix2QcnpUC9XeYVDzx3, review of record) — PR #4120.

    Ordering handled correctly (#4113 already on main → normal branch, no stack). The card's "measure, don't assume" clause was honored twice over: the init scaffold has exactly the one TS2882 and none of #4113's other four error classes (16 of its 17 lived in files this scaffold doesn't have), and a SECOND measurement with paths-mapped workspace sources made visible what the bare-specifier exemption would otherwise hide — all three templates clean beyond the single known error. The gate extension pins the real thing (the scaffold's build script genuinely runs tsc; the three templates share one src tree so one run judges all), and the reverse verification went three-for-three including the self-test's own nothing-to-revert tripwire. The design note (test-gated duplication of a 40-char ecosystem string over coupling init to the temp-app generator's module load path) is the right default and is recorded where a reviewer can overturn it. Also worth keeping from this report: the git checkout <branch> -- restore-before-first-commit trap, documented with the correct form (git diff > patch).

    objectui init → npm run build now works out of the box. Flipping ready + auto-merge.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions