Skip to content

Commit 193f693

Browse files
author
Six Ash
committed
Document new postprocessor option for writeFile
1 parent 2241e3d commit 193f693

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,18 @@ Returns `DtsContent` instance.
143143
### class DtsContent
144144
DtsContent instance has `*.d.ts` content, final output path, and function to write file.
145145

146-
#### `writeFile() => Promise(dtsContent)`
147-
Writes the DtsContent instance's content to a file.
146+
#### `writeFile(postprocessor) => Promise(dtsContent)`
147+
Writes the DtsContent instance's content to a file. Returns the DtsContent instance.
148148

149-
* `dtsContent`: the DtsContent instance itself.
149+
* `postprocessor` (optional): a function that takes the formatted definition string and returns a modified string that will be the final content written to the file.
150+
151+
You could use this, for example, to pass generated definitions through a formatter like Prettier, or to add a comment to the top of generated files:
152+
153+
```js
154+
dtsContent.writeFile(
155+
definition => `// Generated automatically, do not edit\n${definition}`
156+
)
157+
```
150158

151159
#### `tokens`
152160
An array of tokens retrieved from input CSS file.

0 commit comments

Comments
 (0)