postcss / postcss-cli

CLI for postcss
Other
840 stars 93 forks source link

Write `.css.d.ts` file if `result.dts` has contents #329

Closed jednano closed 4 years ago

jednano commented 4 years ago

If result.dts has contents, please output a .d.ts file adjacent to the CSS file.

if (result.dts) {
  tasks.push(fs.outputFile(options.to + '.d.ts', result.dts));
}
RyanZim commented 4 years ago

How does the result.dts property get created? Not seeing it in the docs; just trying to understand the pipeline here.

jednano commented 4 years ago

It's not in the docs. I have a closed source plugin that assigns a string to this property, but really anyone should be able to assign type definitions to a CSS file (or any file for that matter).

I can tell you that if you import type Foo from './foo.css' and there is an adjacent file named ./foo.css.d.ts that TypeScript picks it up and that's exactly what I need.

Or you could be using CSS Modules and importing the actuall css file as a dependency. Same thing, TypeScript will pick it up.

RyanZim commented 4 years ago

Closing, since this is non-standard.