Skip to content

fix(types): add type declarations for CSS-only style imports to resolve TS2882#22769

Closed
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:fix/styles-ts2882-type-declarations
Closed

fix(types): add type declarations for CSS-only style imports to resolve TS2882#22769
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:fix/styles-ts2882-type-declarations

Conversation

@mixelburg
Copy link
Copy Markdown
Contributor

Summary

Fixes #22766

Problem

TypeScript 5.2 introduced error TS2882: "Cannot find module or type declarations for side-effect import of 'vuetify/styles'". This affects any project that imports vuetify/styles (or the sub-paths vuetify/styles/colors, vuetify/styles/core, vuetify/styles/utilities) with strict type checking enabled (e.g. via vue-tsc or tsc).

The root cause is that the ./styles (and related) entries in package.json's exports map don't have a "types" condition, so TypeScript doesn't know where to find type declarations.

Fix

  • Add stub export {} declaration files in src/styles/ for each affected entry point (main.d.ts, colors.d.ts, core.d.ts, utilities.d.ts). The existing build step (babel src --out-dir lib --copy-files) already copies .d.ts files from src/ to lib/, so the built package will include them automatically.
  • Add "types" conditions pointing to those files in the ./styles, ./styles/colors, ./styles/core, and ./styles/utilities exports in package.json.

Tested

With this patch applied and lib/styles/*.d.ts present, import "vuetify/styles" resolves without TS2882 in both tsc and vue-tsc.

…ve TS2882

TypeScript 5.2 introduced TS2882 ('Cannot find module or type
declarations for side-effect import') for CSS-only exports that lack a
'types' condition in package.json. This affects users who run vue-tsc or
tsc strict and import 'vuetify/styles' (and related paths).

Fix: add stub .d.ts files for each style entry point (main, colors, core,
utilities) so TypeScript finds declarations without side-effects. Also add
the 'types' condition to the relevant exports in package.json.

Fixes vuetifyjs#22766
@J-Sek
Copy link
Copy Markdown
Contributor

J-Sek commented Mar 28, 2026

it is about TS 6.0

how did you verify this fix is working?

@KaelWD
Copy link
Copy Markdown
Member

KaelWD commented Mar 30, 2026

2098fb1

@KaelWD KaelWD closed this Mar 30, 2026
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.

[Bug Report][4.0.4] error TS2882: Cannot find module or type declarations for side-effect import of 'vuetify/styles'.

3 participants