shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
75.13k stars 4.69k forks source link

Fix: Separate `VariantProps` and `cva` imports to comply with `verbatimModuleSyntax` #5795

Closed ThomasJ0nes closed 1 day ago

ThomasJ0nes commented 1 week ago

This commit resolves a TypeScript build issue caused by the combined import of VariantProps (a type) and cva (a runtime value) from class-variance-authority.

Context

When verbatimModuleSyntax is enabled, TypeScript enforces strict separation of type-only imports (import type) and runtime imports (import). The current code:

import { VariantProps, cva } from "class-variance-authority";

causes the following build error in strict TypeScript environments (e.g., Vercel deployments):

Type error: 'VariantProps' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

Changes Made Updated the import statement to:

import { cva } from "class-variance-authority"; // For runtime use
import type { VariantProps } from "class-variance-authority"; // For type-checking only

This ensures compliance with verbatimModuleSyntax while preserving the functionality of the existing code. Testing Performed:

vercel[bot] commented 1 week ago

@ThomasJ0nes is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.