postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.15k stars 66 forks source link

In-project typescript .d.ts has wrong type? #88

Closed AviVahl closed 4 years ago

AviVahl commented 4 years ago

New in-project .d.ts declares an export default of a function that returns a plugin, which does not match the actual library.

@types/postcss-nested got it right: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/postcss-nested/index.d.ts

Above .d.ts declares a commonjs module that exports a plugin.

FYI @ai

ai commented 4 years ago

New in-project .d.ts declares an export default of a function that returns a plugin, which does not match the actual library.

Yeap, this is what postcss.plugin generates. You will use it as postcss([ nested() ]).

AviVahl commented 4 years ago

Odd. Up until now we just passed nested in and it worked. We didn't have to call it as a function. New types disallow using the exported value as a plugin itself.

I'll just call it obviously, but this is a breaking type change for those who used @types/postcss-nested.

ai commented 4 years ago

Odd. Up until now we just passed nested in and it worked.

Yeap, PostCSS can call this function for you

New types disallow using the exported value as a plugin itself.

Let’s fix @types/postcss-nested. But I do not use TS and not familiar how to fix it.

AviVahl commented 4 years ago

Actually, @types/postcss-nested can be removed, now that you include an inline .d.ts. I'll make a PR to update the types in postcss-nested.

AviVahl commented 4 years ago

btw, the postcss.Plugin type is exactly that function that can be passed or called. I've checked postcss's .d.ts.