Skip to content

Commit 05d906f

Browse files
Merge pull request #25 from sharunkumar/master
fix: typing and tests in strict mode, and fix build failure
2 parents a24220d + 9b9e163 commit 05d906f

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
"@babel/core": "^7.9.0",
4141
"@babel/preset-env": "^7.9.5",
4242
"@babel/preset-typescript": "^7.9.0",
43-
"@types/jest": "^25.2.1",
44-
"babel-jest": "^25.3.0",
45-
"chalk": "^4.0.0",
43+
"@types/jest": "^29.5.1",
44+
"babel-jest": "^29.5.0",
45+
"chalk": "^5.2.0",
4646
"husky": "^4.2.5",
47-
"jest": "^25.3.0",
48-
"lint-staged": "^10.1.4",
47+
"jest": "^29.5.0",
48+
"lint-staged": "^13.2.2",
4949
"prettier": "^2.0.4",
50-
"rimraf": "^3.0.2",
51-
"ts-jest": "^25.3.1",
52-
"ts-node": "^8.8.2",
53-
"typescript": "^3.8.3"
50+
"rimraf": "^5.0.0",
51+
"ts-jest": "^29.1.0",
52+
"ts-node": "^10.9.1",
53+
"typescript": "^5.0.4"
5454
},
5555
"husky": {
5656
"hooks": {
@@ -66,4 +66,4 @@
6666
"engines": {
6767
"node": ">=8.0.0"
6868
}
69-
}
69+
}

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)