Skip to content

Commit 18bd70a

Browse files
docs(readme): added types in readme (#568)
1 parent a5951e0 commit 18bd70a

File tree

1 file changed

+67
-25
lines changed

1 file changed

+67
-25
lines changed

README.md

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,22 @@ And run `webpack` via your preferred method.
142142

143143
## Options
144144

145-
| Name | Type | Default | Description |
146-
| :---------------------------------: | :------------------: | :-----------------------------------: | :------------------------------------------- |
147-
| [`execute`](#execute) | `{Boolean}` | `undefined` | Enable PostCSS Parser support in `CSS-in-JS` |
148-
| [`postcssOptions`](#postcssOptions) | `{Object\|Function}` | `defaults values for Postcss.process` | Set `PostCSS` options and plugins |
149-
| [`sourceMap`](#sourcemap) | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps |
150-
| [`implementation`](#implementation) | `{Function\|String}` | `postcss` | Setup PostCSS implementation to use |
145+
- [`execute`](#execute)
146+
- [`postcssOptions`](#postcssOptions)
147+
- [`sourceMap`](#sourcemap)
148+
- [`implementation`](#implementation)
151149

152150
### `execute`
153151

154-
Type: `Boolean`
152+
Type:
153+
154+
```ts
155+
type execute = boolean;
156+
```
157+
155158
Default: `undefined`
156159

160+
Enable PostCSS Parser support in `CSS-in-JS`.
157161
If you use JS styles the [`postcss-js`](https://github.com/postcss/postcss-js) parser, add the `execute` option.
158162

159163
**webpack.config.js**
@@ -187,7 +191,28 @@ module.exports = {
187191

188192
### `postcssOptions`
189193

190-
Type: `Object|Function`
194+
Type:
195+
196+
```ts
197+
type postcssOptions =
198+
| {
199+
from: string;
200+
map: boolean | SourceMapOptions;
201+
parser: string | object | (() => Parser);
202+
stringifier: Stringifier | Syntax;
203+
syntax: Syntax;
204+
to: string;
205+
}
206+
| ((loaderContext: LoaderContext) => {
207+
from: string;
208+
map: boolean | SourceMapOptions;
209+
parser: string | object | (() => Parser);
210+
stringifier: Stringifier | Syntax;
211+
syntax: Syntax;
212+
to: string;
213+
});
214+
```
215+
191216
Default: `undefined`
192217

193218
Allows to set [`PostCSS options`](https://postcss.org/api/#processoptions) and plugins.
@@ -198,7 +223,7 @@ There is the special `config` option for config files. How it works and how it c
198223
We recommend do not specify `from`, `to` and `map` options, because this can lead to wrong path in source maps.
199224
If you need source maps please use the [`sourcemap`](#sourcemap) option.
200225

201-
#### `Object`
226+
#### `object`
202227

203228
Setup `plugins`:
204229

@@ -267,9 +292,9 @@ module.exports = {
267292
loader: "postcss-loader",
268293
options: {
269294
postcssOptions: {
270-
// Can be `String`
295+
// Can be `string`
271296
syntax: "sugarss",
272-
// Can be `Object`
297+
// Can be `object`
273298
syntax: require("sugarss"),
274299
},
275300
},
@@ -292,11 +317,11 @@ module.exports = {
292317
loader: "postcss-loader",
293318
options: {
294319
postcssOptions: {
295-
// Can be `String`
320+
// Can be `string`
296321
parser: "sugarss",
297-
// Can be `Object`
322+
// Can be `object`
298323
parser: require("sugarss"),
299-
// Can be `Function`
324+
// Can be `function`
300325
parser: require("sugarss").parse,
301326
},
302327
},
@@ -322,11 +347,11 @@ module.exports = {
322347
loader: "postcss-loader",
323348
options: {
324349
postcssOptions: {
325-
// Can be `String`
350+
// Can be `string`
326351
stringifier: "sugarss",
327-
// Can be `Object`
352+
// Can be `object`
328353
stringifier: require("sugarss"),
329-
// Can be `Function`
354+
// Can be `function`
330355
stringifier: midas.stringifier,
331356
},
332357
},
@@ -336,7 +361,7 @@ module.exports = {
336361
};
337362
```
338363

339-
#### `Function`
364+
#### `function`
340365

341366
**webpack.config.js**
342367

@@ -375,7 +400,12 @@ module.exports = {
375400

376401
#### `config`
377402

378-
Type: `Boolean|String`
403+
Type:
404+
405+
```ts
406+
type config = boolean | string;
407+
```
408+
379409
Default: `undefined`
380410

381411
Allows to set options using config files.
@@ -392,7 +422,7 @@ The loader will search up the directory tree for configuration in the following
392422

393423
##### Examples of Config Files
394424

395-
Using `Object` notation:
425+
Using `object` notation:
396426

397427
**postcss.config.js** (**recommend**)
398428

@@ -408,7 +438,7 @@ module.exports = {
408438
};
409439
```
410440

411-
Using `Function` notation:
441+
Using `function` notation:
412442

413443
**postcss.config.js** (**recommend**)
414444

@@ -509,7 +539,7 @@ module.exports = {
509539
};
510540
```
511541

512-
#### Boolean
542+
#### `boolean`
513543

514544
Enables/Disables autoloading config.
515545

@@ -561,7 +591,12 @@ module.exports = {
561591

562592
### `sourceMap`
563593

564-
Type: `Boolean`
594+
Type:
595+
596+
```ts
597+
type sourceMap = boolean;
598+
```
599+
565600
Default: depends on the `compiler.devtool` value
566601

567602
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option.
@@ -612,14 +647,21 @@ module.exports = {
612647

613648
### `implementation`
614649

615-
Type: `Function | String`
650+
Type:
651+
652+
```ts
653+
type implementation = object;
654+
```
655+
656+
type of `implementation` should be the same as [postcss.d.ts](https://github.com/postcss/postcss/blob/main/lib/postcss.d.ts)
657+
616658
Default: `postcss`
617659

618660
The special `implementation` option determines which implementation of PostCSS to use. Overrides the locally installed `peerDependency` version of `postcss`.
619661

620662
**This option is only really useful for downstream tooling authors to ease the PostCSS 7-to-8 transition.**
621663

622-
#### Function
664+
#### `function`
623665

624666
**webpack.config.js**
625667

0 commit comments

Comments
 (0)