Skip to content

Commit f2cce1b

Browse files
committed
fix: improve types
Plugin creator needs postcss property set to true. It's more intuitive to use the types if it explicitly returns a PostCSS plugin.
1 parent 1f2513d commit f2cce1b

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

Diff for: src/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import transform from './lib/transform';
66
* warnWhenCannotResolve?: boolean,
77
* mediaQueries?: boolean,
88
* selectors?: boolean}} PostCssCalcOptions
9-
*
9+
*/
10+
/**
11+
* @type {import('postcss').PluginCreator<PostCssCalcOptions>}
1012
* @param {PostCssCalcOptions} opts
13+
* @return {import('postcss').Plugin}
1114
*/
1215
function pluginCreator(opts) {
1316
const options = Object.assign({
@@ -20,10 +23,6 @@ function pluginCreator(opts) {
2023

2124
return {
2225
postcssPlugin: 'postcss-calc',
23-
/**
24-
* @param {import('postcss').Root} css
25-
* @param {{result: import('postcss').Result}} helpers
26-
*/
2726
OnceExit(css, { result }) {
2827
css.walk(node => {
2928
const { type } = node;

Diff for: types/index.d.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,13 @@ export type PostCssCalcOptions = {
1212
* warnWhenCannotResolve?: boolean,
1313
* mediaQueries?: boolean,
1414
* selectors?: boolean}} PostCssCalcOptions
15-
*
16-
* @param {PostCssCalcOptions} opts
1715
*/
18-
declare function pluginCreator(opts: PostCssCalcOptions): {
19-
postcssPlugin: string;
20-
/**
21-
* @param {import('postcss').Root} css
22-
* @param {{result: import('postcss').Result}} helpers
23-
*/
24-
OnceExit(css: import('postcss').Root, { result }: {
25-
result: import('postcss').Result;
26-
}): void;
27-
};
16+
/**
17+
* @type {import('postcss').PluginCreator<PostCssCalcOptions>}
18+
* @param {PostCssCalcOptions} opts
19+
* @return {import('postcss').Plugin}
20+
*/
21+
declare function pluginCreator(opts: PostCssCalcOptions): import('postcss').Plugin;
2822
declare namespace pluginCreator {
29-
const postcss: boolean;
23+
const postcss: true;
3024
}

0 commit comments

Comments
 (0)