Skip to content

Comments

Prevent styles from becoming any type when importing unresolvable or unmatched modules#303

Merged
mizdra merged 1 commit intomainfrom
error-type-guard
Jan 12, 2026
Merged

Prevent styles from becoming any type when importing unresolvable or unmatched modules#303
mizdra merged 1 commit intomainfrom
error-type-guard

Conversation

@mizdra
Copy link
Owner

@mizdra mizdra commented Jan 12, 2026

This is a workaround to avoid the issue described as a "Drawbacks" in #302.

Before

 2026-01-12 18 57 13

After

 2026-01-12 18 55 38

@mizdra mizdra added the Type: Bug Bug or Bug fixes label Jan 12, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2026

🦋 Changeset detected

Latest commit: 6f2f19f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@css-modules-kit/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mizdra
Copy link
Owner Author

mizdra commented Jan 12, 2026

This workaround is the most clever idea I've come up with in the past six months :)

@mizdra mizdra merged commit 0128985 into main Jan 12, 2026
31 of 32 checks passed
@mizdra mizdra deleted the error-type-guard branch January 12, 2026 10:15
@github-actions github-actions bot mentioned this pull request Jan 12, 2026
// It uses the technique from https://stackoverflow.com/a/55541672 to fall back from `any` to `{}`.
// However, the import type for an unresolvable specifier becomes a special `any` type called `errorType`.
// The technique from https://stackoverflow.com/a/55541672 does not work with `errorType`.
// Therefore, this combines it with the approach from https://github.com/microsoft/TypeScript/issues/62972.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant