Skip to content

Commit 3953d84

Browse files
committed
Add strict to tsconfig.json
1 parent 3506854 commit 3953d84

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ import {position} from 'unist-util-position'
3737
import {webNamespaces} from 'web-namespaces'
3838
import {zwitch} from 'zwitch'
3939

40+
const ns = /** @type {Record<string, string>} */ (webNamespaces)
41+
4042
const own = {}.hasOwnProperty
4143

4244
const one = zwitch('type', {
45+
// @ts-expect-error: hush.
4346
handlers: {root, element, text, comment, doctype},
4447
invalid,
48+
// @ts-expect-error: hush.
4549
unknown
4650
})
4751

@@ -65,7 +69,6 @@ function unknown(value) {
6569
*/
6670
export function toXast(tree, options) {
6771
const space = typeof options === 'string' ? options : (options || {}).space
68-
// @ts-ignore types are wrong.
6972
return one(tree, {schema: space === 'svg' ? svg : html, ns: null})
7073
}
7174

@@ -138,7 +141,7 @@ function element(node, parentConfig) {
138141
/** @type {Context} */
139142
const config = Object.assign({}, parentConfig, {
140143
schema,
141-
ns: webNamespaces[schema.space]
144+
ns: schema.space ? ns[schema.space] : undefined
142145
})
143146

144147
if (parentConfig.ns !== config.ns) {
@@ -182,7 +185,6 @@ function element(node, parentConfig) {
182185
attributes[info.attribute] = value
183186
}
184187

185-
// @ts-ignore Assume no `doctypes` in `element.`
186188
return patch(
187189
node,
188190
/** @type {XastElement} */ ({
@@ -214,7 +216,7 @@ function all(origin, config) {
214216
}
215217

216218
while (++index < origin.children.length) {
217-
// @ts-ignore `zwitch` types are wrong.
219+
// @ts-expect-error `zwitch` types are wrong.
218220
result[index] = one(origin.children[index], config)
219221
}
220222

test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('toXast', (t) => {
1212

1313
t.throws(
1414
() => {
15-
// @ts-ignore runtime.
15+
// @ts-expect-error runtime.
1616
toXast()
1717
},
1818
/Error: Expected node, not `undefined`/,
@@ -21,7 +21,7 @@ test('toXast', (t) => {
2121

2222
t.throws(
2323
() => {
24-
// @ts-ignore well-known.
24+
// @ts-expect-error well-known.
2525
toXast({type: 'raw', value: '<script>alert(1)</script>'})
2626
},
2727
/Error: Cannot transform node of type `raw`/,
@@ -87,7 +87,7 @@ test('toXast', (t) => {
8787
)
8888

8989
t.deepEqual(
90-
// @ts-ignore runtime.
90+
// @ts-expect-error runtime.
9191
toXast(u('text')),
9292
u('text', ''),
9393
'should support a void text node'
@@ -104,7 +104,7 @@ test('toXast', (t) => {
104104
)
105105

106106
t.deepEqual(
107-
// @ts-ignore runtime.
107+
// @ts-expect-error runtime.
108108
toXast(u('comment')),
109109
u('comment', ''),
110110
'should support a void comment node'
@@ -115,7 +115,7 @@ test('toXast', (t) => {
115115

116116
t.test('doctype', (t) => {
117117
t.deepEqual(
118-
// @ts-ignore hast@next.
118+
// @ts-expect-error hast@next.
119119
toXast(u('doctype')),
120120
u('doctype', {name: 'html', public: undefined, system: undefined}),
121121
'should support a doctype node'

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"declaration": true,
1111
"emitDeclarationOnly": true,
1212
"allowSyntheticDefaultImports": true,
13-
"skipLibCheck": true
13+
"skipLibCheck": true,
14+
"strict": true
1415
}
1516
}

0 commit comments

Comments
 (0)