Skip to content

Commit 349f7ae

Browse files
committed
Add strict to tsconfig.json
1 parent 3454b75 commit 349f7ae

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,29 @@ export const filter =
6868
if (node.children) {
6969
childIndex = -1
7070

71-
// @ts-ignore Looks like a parent.
71+
// @ts-expect-error Looks like a parent.
7272
while (++childIndex < node.children.length) {
73-
// @ts-ignore Looks like a parent.
73+
// @ts-expect-error Looks like a parent.
7474
result = preorder(node.children[childIndex], childIndex, node)
7575

7676
if (result) {
7777
children.push(result)
7878
}
7979
}
8080

81-
// @ts-ignore Looks like a parent.
81+
// @ts-expect-error Looks like a parent.
8282
if (cascade && node.children.length > 0 && children.length === 0)
8383
return null
8484
}
8585

8686
// Create a shallow clone, using the new children.
8787
/** @type {typeof node} */
88-
// @ts-ignore all the fields will be copied over.
88+
// @ts-expect-error all the fields will be copied over.
8989
const next = {}
9090

9191
for (key in node) {
92-
/* istanbul ignore else - Prototype injection. */
9392
if (own.call(node, key)) {
93+
// @ts-expect-error: Looks like a record.
9494
next[key] = key === 'children' ? children : node[key]
9595
}
9696
}

test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {filter} from './index.js'
99

1010
test('should not traverse into children of filtered out nodes', (t) => {
1111
const tree = u('root', [u('node', [u('leaf', '1')]), u('leaf', '2')])
12+
/** @type {Record<string, number>} */
1213
const types = {}
1314

1415
t.deepEqual(filter(tree, predicate), u('root', [u('leaf', '2')]))
@@ -71,25 +72,26 @@ test('should not cascade-remove nodes that were empty initially', (t) => {
7172

7273
test('should call iterator with `index` and `parent` args', (t) => {
7374
const tree = u('root', [u('node', [u('leaf', '1')]), u('leaf', '2')])
74-
/** @type {Array.<[Node, number|undefined, Parent|undefined]>} */
75+
/** @type {Array.<[Node, number|null|undefined, Parent|null|undefined]>} */
7576
const callLog = []
7677

77-
t.deepEqual(filter(tree, predicate), tree)
78+
t.deepEqual(
79+
filter(tree, (a, b, c) => {
80+
callLog.push([a, b, c])
81+
return true
82+
}),
83+
tree
84+
)
7885

7986
t.deepEqual(callLog, [
8087
[tree, undefined, undefined],
8188
[tree.children[0], 0, tree],
82-
// @ts-ignore yeah, it exists.
89+
// @ts-expect-error yeah, it exists.
8390
[tree.children[0].children[0], 0, tree.children[0]],
8491
[tree.children[1], 1, tree]
8592
])
8693

8794
t.end()
88-
89-
function predicate() {
90-
callLog.push([].slice.call(arguments))
91-
return true
92-
}
9395
})
9496

9597
test('should support type and node tests', (t) => {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"emitDeclarationOnly": true,
1212
"allowSyntheticDefaultImports": true,
1313
"skipLibCheck": true,
14-
"strictNullChecks": true
14+
"strictNullChecks": true,
15+
"strict": true
1516
}
1617
}

0 commit comments

Comments
 (0)