Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Modules are not recognized as TypeScript modules #18259

Open
jackson-bean opened this issue Mar 17, 2025 · 2 comments · May be fixed by #18270
Open

CSS Modules are not recognized as TypeScript modules #18259

jackson-bean opened this issue Mar 17, 2025 · 2 comments · May be fixed by #18270
Labels
bug Something isn't working css CSS parser, bundler-related types An issue with TypeScript types

Comments

@jackson-bean
Copy link

What version of Bun is running?

1.2.5+013fdddc6

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

  • bun init with React template
  • Attempt to import a .module.css file

What is the expected behavior?

Since the docs advertise CSS Modules support, it's expected to not have to define the TypeScript types for them manually.

What do you see instead?

TypeScript error Cannot find module '*.module.css' or its corresponding type declarations.ts (2307)

Additional information

This can be worked around by adding

declare module '*.module.css' {
    const classes: { readonly [key: string]: string }
    export default classes
}

to a .d.ts file, but it feels off to have to do so.

@jackson-bean jackson-bean added bug Something isn't working types An issue with TypeScript types labels Mar 17, 2025
@RiskyMH
Copy link
Member

RiskyMH commented Mar 18, 2025

Oh lol yeah this should be added to @types/bun

Feel free to make a PR updating https://github.com/oven-sh/bun/blob/main/packages/bun-types/ambient.d.ts

@RiskyMH RiskyMH added the css CSS parser, bundler-related label Mar 18, 2025
@jackson-bean
Copy link
Author

Oh lol yeah this should be added to @types/bun

Feel free to make a PR updating https://github.com/oven-sh/bun/blob/main/packages/bun-types/ambient.d.ts

Done

@RiskyMH RiskyMH linked a pull request Mar 18, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working css CSS parser, bundler-related types An issue with TypeScript types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants