timocov / dts-bundle-generator

A tool to generate a single bundle of dts with types tree-shaking
MIT License
762 stars 40 forks source link

TS2307: Cannot find module *.module.css #300

Closed theStrangeAdventurer closed 9 months ago

theStrangeAdventurer commented 9 months ago

Bug report Hi! When i'm trying to build my d.ts file dts-bundle-generator -o ./dist/types/index.d.ts index.ts I'm facing the following error:

error TS2307: Cannot find module './styles.module.css' or its corresponding type declarations.

It's worth noting that the TypeScript compiler have no issues with build and tsc works completely fine. Also i have declaration.d.ts which contain following:

declare module '*.module.css' {
    const classes: Readonly<Record<string, string>>
    export default classes
}

Expected output // Nothing, it just works

Actual output

// src/index.tsx(2,20): error TS2307: Cannot find module './styles.module.css' or its corresponding type declarations.

Any insights or help on resolving this would be greatly appreciated. Thanks!

timocov commented 9 months ago

See https://github.com/timocov/dts-bundle-generator/discussions/232