fix(types): add type declarations for CSS-only style imports to resolve TS2882#22769
Closed
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
Closed
fix(types): add type declarations for CSS-only style imports to resolve TS2882#22769mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
Conversation
…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
Contributor
|
it is about TS 6.0 how did you verify this fix is working? |
Member
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
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-pathsvuetify/styles/colors,vuetify/styles/core,vuetify/styles/utilities) with strict type checking enabled (e.g. viavue-tscortsc).The root cause is that the
./styles(and related) entries inpackage.json'sexportsmap don't have a"types"condition, so TypeScript doesn't know where to find type declarations.Fix
export {}declaration files insrc/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.tsfiles fromsrc/tolib/, so the built package will include them automatically."types"conditions pointing to those files in the./styles,./styles/colors,./styles/core, and./styles/utilitiesexports inpackage.json.Tested
With this patch applied and
lib/styles/*.d.tspresent,import "vuetify/styles"resolves without TS2882 in bothtscandvue-tsc.