Skip to content

fix(registry): use type-only imports (fixes TS1484 in stock Vite react-ts apps) - #993

Merged
Yeom-JinHo merged 2 commits into
magicuidesign:mainfrom
noron12234:fix/type-only-imports
Jul 31, 2026
Merged

fix(registry): use type-only imports (fixes TS1484 in stock Vite react-ts apps)#993
Yeom-JinHo merged 2 commits into
magicuidesign:mainfrom
noron12234:fix/type-only-imports

Conversation

@noron12234

Copy link
Copy Markdown
Contributor

The problem

Registry components import type-only bindings as value imports:

// registry/magicui/spinning-text.tsx
import React, { type ComponentPropsWithoutRef } from "react"
import { motion, Transition, Variants } from "motion/react"
//              ^^^^^^^^^^^^^^^^^^^^ the line above already writes `type`

// registry/magicui/border-beam.tsx
import { motion, MotionStyle, Transition } from "motion/react"

// registry/magicui/comic-text.tsx
import { CSSProperties } from "react"

verbatimModuleSyntax is on by default in the scaffold TypeScript itself generates — npm create vite@latest -- --template react-ts writes it into tsconfig.app.json. So for anyone installing one of these components into a stock Vite app, these are hard TS1484 build errors, not warnings.

Reproduction (before)

$ npm create vite@latest demo -- --template react-ts
$ cd demo && npm i && npm i motion clsx tailwind-merge class-variance-authority
# npx shadcn@latest add https://magicui.design/r/spinning-text.json  (etc.)
$ npm run build

src/blocks/border-beam.tsx(3,18): error TS1484: 'MotionStyle' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/blocks/border-beam.tsx(3,31): error TS1484: 'Transition' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/blocks/comic-text.tsx(3,10): error TS1484: 'CSSProperties' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/blocks/spinning-text.tsx(4,18): error TS1484: 'Transition' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/blocks/spinning-text.tsx(4,30): error TS1484: 'Variants' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

After

$ npm run build
✓ built in 148ms
before after
tsc --noEmit --verbatimModuleSyntax in apps/www 43 TS1484 0
consumer build (stock react-ts template, 3 components) fails passes
pre-existing unrelated errors 55 55 (untouched)
prettier --check on changed files clean clean
eslint on changed files clean clean

The change

Adds the inline type modifier at 43 specifiers across 33 files — 23 of them in registry/, the rest in the site's own code so the whole class is gone rather than half of it.

The generated payloads matter here. public/r/*.json embeds the component source verbatim, and that string is what the CLI writes into a user's project — fixing only the .tsx sources would have left the shipped payload broken. So the registry was rebuilt (scripts/build-registry.mts) after formatting, and 16 generated files carry the change through:

$ jq -r '.files[].content' apps/www/public/r/spinning-text.json | grep motion/react
import { motion, type Transition, type Variants } from "motion/react"

Affected bindings: Transition Variants MotionStyle MotionProps HTMLMotionProps (motion) · CSSProperties ReactNode ReactElement FC (react) · VariantProps (cva) · Metadata MetadataRoute ImageProps (next) · RegistryItem (shadcn/schema).

Verification

  • npx tsc --noEmit --verbatimModuleSyntax in apps/www: TS1484 count 43 → 0. The 55 pre-existing unrelated errors are unchanged — this PR does not claim to fix those.
  • Diff audited mechanically: every source hunk is a type insertion, 0 non-trivial changes. The extra lines in the stat are Prettier rewrapping imports that crossed the print width.
  • Formatted first, then regenerated the registry, so the embedded content matches the formatted source.
  • Built the patched spinning-text / border-beam / comic-text in a stock Vite React-TS app: compiles and bundles clean.

Optional follow-up

Setting "verbatimModuleSyntax": true in apps/www/tsconfig.json would stop this class coming back — it shows up in-editor immediately. Left out of this PR on purpose so the diff stays mechanical; happy to add it if you want it.

Registry components import type-only bindings (Transition, Variants,
MotionStyle, HTMLMotionProps, CSSProperties, ReactNode, VariantProps, ...)
as value imports.

TypeScript's own `--template react-ts` scaffold turns on
`verbatimModuleSyntax`, so every one of these is a hard TS1484 compile error
the moment someone installs a component into a stock Vite app.

The generated payloads under public/r embed the component source verbatim,
so the registry was rebuilt too — that is what the CLI actually writes into
a user's project.

43 specifiers across 33 files, plus the regenerated registry output. Adds
the inline `type` modifier, matching the style already used in the same
import statements (spinning-text.tsx already writes
`type ComponentPropsWithoutRef` one line above). No runtime or type
semantics change.
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@noron12234 is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

@Yeom-JinHo
Yeom-JinHo self-requested a review July 31, 2026 11:02
The previous commit removed every type-only binding imported as a value,
so the flag turns on with zero additional changes (tsc --noEmit passes).
New registry code that reintroduces the pattern now fails in-editor and
in CI instead of surfacing as a build error in consumers' Vite apps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BPdQpL26E46TqVKrBFKrgH

@Yeom-JinHo Yeom-JinHo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noron12234
Thanks for the contribution 👍🏽

@Yeom-JinHo
Yeom-JinHo merged commit 58ee1fe into magicuidesign:main Jul 31, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants