Skip to content

CSS Modules are not recognized as TypeScript modules #18259

Closed
@jackson-bean

Description

@jackson-bean

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcssCSS parser, bundler-relatedtypesAn issue with TypeScript types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions