Skip to content

Commit 6b5c6f8

Browse files
committed
fixed typing and tests in strict mode
1 parent a24220d commit 6b5c6f8

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { IPriorityQueue } from '../typings/priority-queue';
3131
*/
3232
export class PriorityQueue<T> implements IPriorityQueue<T> {
3333
private _queue: T[];
34-
private _comparator: (item1: T, item2: T) => boolean;
34+
private _comparator?: (item1: T, item2: T) => boolean;
3535

3636
constructor(comparator?: (item1: T, item2: T) => boolean) {
3737
this._queue = [];

test/priority-queue.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('testing priority queue', () => {
1616
});
1717

1818
afterEach(() => {
19-
p = null;
19+
p = new PriorityQueue();
2020
});
2121

2222
it('should return max heap of test case 1', () => {
@@ -193,7 +193,7 @@ describe('testing priority queue', () => {
193193
});
194194

195195
afterEach(() => {
196-
p = null;
196+
p = new PriorityQueue();
197197
});
198198

199199
it('should return min heap of test case 1', () => {
@@ -233,7 +233,7 @@ describe('testing priority queue', () => {
233233
});
234234

235235
afterEach(() => {
236-
p = null;
236+
p = new PriorityQueue();
237237
});
238238

239239
it('should return true - with array of numbers', () => {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"compilerOptions": {
66
"outDir": "./dist",
77
"noImplicitAny": false,
8-
"noImplicitUseStrict": true,
98
"module": "CommonJS",
109
"target": "ESNext",
1110
"allowJs": true,
1211
"moduleResolution": "node",
1312
"esModuleInterop": true,
13+
"strict": true,
1414
"lib": [
1515
"ES2015",
1616
"DOM"

typings/priority-queue.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export interface IPriorityQueue<T> {
1010
/**
1111
* Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
1212
*/
13-
top: () => T;
13+
top: () => T | null;
1414
/**
1515
* Retrieves and removes the head of this queue, or returns null if this queue is empty.
1616
* Everytime pop element from queue, the queue is started "sift down" to rebuild the heap
1717
*/
18-
pop: () => T;
18+
pop: () => T | null;
1919
/**
2020
* Returns the number of elements in this collection.
2121
*/

0 commit comments

Comments
 (0)