Repository navigation
Conversation
The TS variants of components that import three or matter-js only listed the runtime package, so the CLI never installed its type definitions and tsc failed with TS7016. Add the matching @types package as a devDependency for those variants, taking the version from package.json, and regenerate the 16 affected registry files. Closes DavidHDev#1112
This branch has not been deployed
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.
Summary
The TypeScript variants of components that import
threeormatter-jsnow also install the matching@types/*package, so a TS project compiles right aftershadcn addwithout manual steps.Closes #1112
Problem
threeandmatter-jsdon't ship their own type definitions, but the TS registry items only listed the runtime package underdependencies. For exampleLanyard-TS-CSS.jsonhadthree@^0.180.0and nothing else, so after installing the componenttscreports:It isn't specific to pnpm; the registry content is the same whichever package manager runs the install.
Solution
@jsrepo/shadcnonly writesdependenciesto the item JSON, so the types are added injsrepo.config.ts, in the same placewithLinkedDependenciesalready post-processes the generated files:defineComponentscans the files of each TS variant for imports ofthree,@react-three/fiber,@react-three/dreiandmatter-js, and maps them to@types/three/@types/matter-js.devDependencies(the shadcn registry-item schema supports the field, and the CLI installs them with-D).devDependencies, so they stay in line with the runtime packages. Adding a package toTYPES_PACKAGESis all it takes to cover another one later.JS variants are untouched, and no component code changed.
Changes
jsrepo.config.ts@types, write them asdevDependenciespublic/r/*-TS-CSS.json,public/r/*-TS-TW.jsonAffected components: BlobCursor, ColorBends, Hyperspeed, Lanyard, ModelViewer, PaperCrumple (
@types/three) and FallingText, FolderFloat (@types/matter-js).Before / After
Lanyard-TS-CSS.json:
How to test
npm run registry:buildgit status public/rshould show only the 16 TS files above, and none of the*-JS-*files.npx shadcn@latest add <path or URL of Lanyard-TS-CSS.json>;@types/threeis added todevDependenciesnext tothree.Testing done
Ran in GitHub Actions on my fork (run):
npm ciandnpx jsrepo buildpass; exactly the 16 expected files change, and none of the JS variants gained adevDependenciesfield.threeand strict TypeScript fails withTS7016before adding@types/threeand compiles cleanly after.shadcn addagainst the rebuiltLanyard-TS-CSS.jsoncreatedLanyard.cssandLanyard.tsxand putthreeindependenciesand@types/threeindevDependencies.prettier --check jsrepo.config.tspasses.Not covered: I only tried the shadcn CLI. I haven't run
jsrepo addagainst the new files, and I haven't checked every one of the 8 components in a real app. I also didn't addupdatesentries inInformation.js, since no component code changed; happy to add them if you'd like them on the changelog.Notes
@types/matter-jscomes from the repo's existing^0.19.8pin, whilematter-jsis^0.20.0; bumping that is a separate decision.