seek-oss / css-modules-typescript-loader

Webpack loader to create TypeScript declarations for CSS Modules
MIT License
198 stars 27 forks source link

Generate app.d.css.ts instead of app.css.d.ts #49

Open bhollis opened 1 year ago

bhollis commented 1 year ago

TypeScript now supports an allowArbitraryExtensions setting, which allows it to properly find definitions for app.css in app.d.css.ts. From their docs:

Note that historically, a similar effect has often been achievable by adding a declaration file named app.css.d.ts instead of app.d.css.ts - however, this just worked through Node’s require resolution rules for CommonJS. Strictly speaking, the former is interpreted as a declaration file for a JavaScript file named app.css.js. Because relative files imports need to include extensions in Node’s ESM support, TypeScript would error on our example in an ESM file under --moduleResolution node16 or nodenext.