Skip to content

Commit 0f8f0ae

Browse files
authoredAug 29, 2021
Add missing nulls in the type declaration (w8r#45)
* Add missing nulls in the type declaration * Remove useless tests/types.ts & add --strict for tsc
1 parent d85e7f2 commit 0f8f0ae

File tree

3 files changed

+11
-65
lines changed

3 files changed

+11
-65
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"prebuild": "npm run lint",
2121
"lint": "eslint src",
2222
"build": "rollup -c && npm run types",
23-
"types": "tsc src/index.d.ts tests/types.ts",
23+
"types": "tsc --strict src/index.d.ts",
2424
"prebenchmark": "npm run build",
2525
"benchmark": "node bench/benchmark.js",
2626
"start": "npm run test:watch",

‎src/index.d.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ export default class AVLTree<Key extends any, Value extends any> {
1515
size: number;
1616
insert(key: Key, data?: Value): Node<Key, Value>;
1717
remove(key: Key): Node<Key, Value>;
18-
find(key: Key): Node<Key, Value>;
19-
at(index: number): Node<Key, Value>;
18+
find(key: Key): Node<Key, Value> | null;
19+
at(index: number): Node<Key, Value> | null;
2020
contains(key: Key): boolean;
2121
isEmpty(): boolean;
2222
keys(): Array<Key>;
2323
values(): Array<Value>;
24-
pop(): Node<Key, Value>;
25-
popMax(): Node<Key, Value>;
26-
min(): Key;
27-
max(): Key;
28-
minNode(): Node<Key, Value>;
29-
maxNode(): Node<Key, Value>;
24+
pop(): Node<Key, Value> | null;
25+
popMax(): Node<Key, Value> | null;
26+
min(): Key | null;
27+
max(): Key | null;
28+
minNode(): Node<Key, Value> | null;
29+
maxNode(): Node<Key, Value> | null;
3030
forEach(callback: ForEachCallback<Key, Value>): AVLTree<Key, Value>;
3131
range(minKey: Key, maxKey: Key, visit: TraverseCallback<Key, Value>, context?: any): AVLTree<Key, Value>;
3232
load(keys: Array<Key>, values?: Array<Value>, presort?: boolean): AVLTree<Key, Value>;
33-
prev(node: Node<Key, Value>): Node<Key, Value>;
34-
next(node: Node<Key, Value>): Node<Key, Value>;
33+
prev(node: Node<Key, Value>): Node<Key, Value> | null;
34+
next(node: Node<Key, Value>): Node<Key, Value> | null;
3535
isBalanced(): boolean;
3636
toString(): string;
3737
destroy(): AVLTree<Key, Value>;

‎tests/types.ts

-54
This file was deleted.

0 commit comments

Comments
 (0)