Skip to content

Commit 0dc5101

Browse files
authored
types: make optional fields optional
Closes GH-20. Reviewed-by: Christian Murphy <[email protected]> Reviewed-by: Titus Wormer <[email protected]>
1 parent 94bd26e commit 0dc5101

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"html-void-elements": "^1.0.0",
3939
"property-information": "^5.0.0",
4040
"space-separated-tokens": "^1.0.0",
41-
"stringify-entities": "^3.0.0",
41+
"stringify-entities": "^3.0.1",
4242
"unist-util-is": "^4.0.0",
4343
"xtend": "^4.0.0"
4444
},

types/index.d.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare namespace hastUtilToHtml {
1212
*
1313
* @defaultValue 'html'
1414
*/
15-
space: 'html' | 'svg'
15+
space?: 'html' | 'svg'
1616

1717
/**
1818
* Configuration for `stringify-entities`.
@@ -21,9 +21,10 @@ declare namespace hastUtilToHtml {
2121
*
2222
* @defaultValue {}
2323
*/
24-
entities: Partial<
25-
/* eslint-disable-next-line @typescript-eslint/ban-types */
26-
Omit<StringifyEntitiesOptions, 'escapeOnly' | 'attribute' | 'subset'>
24+
/* eslint-disable-next-line @typescript-eslint/ban-types */
25+
entities?: Omit<
26+
StringifyEntitiesOptions,
27+
'escapeOnly' | 'attribute' | 'subset'
2728
>
2829

2930
/**
@@ -33,29 +34,29 @@ declare namespace hastUtilToHtml {
3334
*
3435
* @defaultValue `require('html-void-elements')`
3536
*/
36-
voids: string[]
37+
voids?: string[]
3738

3839
/**
3940
* Use a `<!DOCTYPE…` instead of `<!doctype…`.
4041
* Useless except for XHTML.
4142
*
4243
* @defaultValue false
4344
*/
44-
upperDoctype: boolean
45+
upperDoctype?: boolean
4546

4647
/**
4748
* Preferred quote to use.
4849
*
4950
* @defaultValue '"'
5051
*/
51-
quote: '"' | "'"
52+
quote?: '"' | "'"
5253

5354
/**
5455
* Use the other quote if that results in less bytes.
5556
*
5657
* @defaultValue false
5758
*/
58-
quoteSmart: boolean
59+
quoteSmart?: boolean
5960

6061
/**
6162
* Leave attributes unquoted if that results in less bytes.
@@ -64,7 +65,7 @@ declare namespace hastUtilToHtml {
6465
*
6566
* @defaultValue false
6667
*/
67-
preferUnquoted: boolean
68+
preferUnquoted?: boolean
6869

6970
/**
7071
* Omit optional opening and closing tags.
@@ -75,7 +76,7 @@ declare namespace hastUtilToHtml {
7576
*
7677
* @defaultValue false
7778
*/
78-
omitOptionalTags: boolean
79+
omitOptionalTags?: boolean
7980

8081
/**
8182
* Collapse empty attributes: `class=""` is stringified as `class` instead.
@@ -85,7 +86,7 @@ declare namespace hastUtilToHtml {
8586
*
8687
* @defaultValue false
8788
*/
88-
collapseEmptyAttributes: boolean
89+
collapseEmptyAttributes?: boolean
8990

9091
/**
9192
* Close self-closing nodes with an extra slash (`/`): `<img />` instead of `<img>`.
@@ -95,7 +96,7 @@ declare namespace hastUtilToHtml {
9596
*
9697
* @defaultValue false
9798
*/
98-
closeSelfClosing: boolean
99+
closeSelfClosing?: boolean
99100

100101
/**
101102
* Close SVG elements without any content with slash (`/`) on the opening tag instead of an end tag: `<circle />` instead of `<circle></circle>`.
@@ -105,22 +106,22 @@ declare namespace hastUtilToHtml {
105106
*
106107
* @defaultValue false
107108
*/
108-
closeEmptyElements: boolean
109+
closeEmptyElements?: boolean
109110

110111
/**
111112
* Do not use an extra space when closing self-closing elements: `<img/>` instead of `<img />`.
112113
* **Note**: Only used if `closeSelfClosing: true` or `closeEmptyElements: true`.
113114
*
114115
* @defaultValue false
115116
*/
116-
tightSelfClosing: boolean
117+
tightSelfClosing?: boolean
117118

118119
/**
119120
* Join known comma-separated attribute values with just a comma (`,`), instead of padding them on the right as well (`,·`, where `·` represents a space).
120121
*
121122
* @defaultValue false
122123
*/
123-
tightCommaSeparatedLists: boolean
124+
tightCommaSeparatedLists?: boolean
124125

125126
/**
126127
* Join attributes together, without white-space, if possible: `class="a b" title="c d"` is stringified as `class="a b"title="c d"` instead to save bytes.
@@ -130,15 +131,15 @@ declare namespace hastUtilToHtml {
130131
*
131132
* @defaultValue false
132133
*/
133-
tightAttributes: boolean
134+
tightAttributes?: boolean
134135

135136
/**
136137
* Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of `<!doctype html>` to save bytes.
137138
* **Note**: creates invalid (but working) markup.
138139
*
139140
* @defaultValue false
140141
*/
141-
tightDoctype: boolean
142+
tightDoctype?: boolean
142143

143144
/**
144145
* Do not encode characters which cause parse errors (even though they work), to save bytes.
@@ -148,15 +149,15 @@ declare namespace hastUtilToHtml {
148149
*
149150
* @defaultValue false
150151
*/
151-
allowParseErrors: boolean
152+
allowParseErrors?: boolean
152153

153154
/**
154155
* Do not encode some characters which cause XSS vulnerabilities in older browsers.
155156
* **Note**: Only set this if you completely trust the content.
156157
*
157158
* @defaultValue false
158159
*/
159-
allowDangerousCharacters: boolean
160+
allowDangerousCharacters?: boolean
160161

161162
/**
162163
* Allow `raw` nodes and insert them as raw HTML.
@@ -165,7 +166,7 @@ declare namespace hastUtilToHtml {
165166
*
166167
* @defaultValue false
167168
*/
168-
allowDangerousHtml: boolean
169+
allowDangerousHtml?: boolean
169170
}
170171
}
171172

@@ -177,7 +178,7 @@ declare namespace hastUtilToHtml {
177178
*/
178179
declare function hastUtilToHtml(
179180
tree: Node | Node[],
180-
options?: Partial<hastUtilToHtml.HastUtilToHtmlOptions>
181+
options?: hastUtilToHtml.HastUtilToHtmlOptions
181182
): string
182183

183184
export = hastUtilToHtml

0 commit comments

Comments
 (0)