Skip to content

Commit c433f46

Browse files
committed
Fix TypeScript build issues
1 parent b7b1d31 commit c433f46

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

__tests__/1-1-top-sort.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { IGraph } from '../src/practice/0-directed-graph';
1+
import { IDirectedGraph } from '../src/practice/0-directed-graph';
22
import { isTopSort, pathExists, topSort } from '../src/practice/1-1-top-sort';
33

4-
export const singleNode: IGraph = {
4+
export const singleNode: IDirectedGraph = {
55
nodes: ['a'],
66
edges: {},
77
};
88

9-
export const loop: IGraph = {
9+
export const loop: IDirectedGraph = {
1010
nodes: ['a'],
1111
edges: { a: ['a'] },
1212
};
1313

14-
export const shortChain: IGraph = {
14+
export const shortChain: IDirectedGraph = {
1515
nodes: ['a', 'b'],
1616
edges: { a: ['b'] },
1717
};
1818

19-
export const longChain: IGraph = {
19+
export const longChain: IDirectedGraph = {
2020
nodes: ['a', 'b', 'c', 'd'],
2121
edges: { a: ['b'], b: ['c'], c: ['d'] },
2222
};
2323

24-
export const linkedChain: IGraph = {
24+
export const linkedChain: IDirectedGraph = {
2525
nodes: ['a', 'b', 'c'],
2626
edges: { a: ['b'], b: ['c'], c: ['a'] },
2727
};

__tests__/3-1-single-array-multiple-stacks.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ describe(MultiStack.name, () => {
6363
describe(DoubleStack.name, () => {
6464
describe(`left stack`, () => {
6565
[
66-
{ capacity: null, values: [ 1 ] },
67-
{ capacity: null, values: [ 1, 2 ] },
68-
{ capacity: null, values: [ 1, 2, 3 ] },
66+
{ capacity: undefined, values: [ 1 ] },
67+
{ capacity: undefined, values: [ 1, 2 ] },
68+
{ capacity: undefined, values: [ 1, 2, 3 ] },
6969
].forEach(testCase => {
7070
it(`Should correctly implement pushLeft(), popLeft(), isEmpty* for ${JSON.stringify(testCase)}`, () => {
7171
const { capacity, values } = testCase;
@@ -86,7 +86,7 @@ describe(DoubleStack.name, () => {
8686
});
8787

8888
[
89-
{ capacity: null, values: [ ] },
89+
{ capacity: undefined, values: [ ] },
9090
].forEach(testCase => {
9191
it(`Should correctly implement pushLeft(), popLeft(), isEmpty* for ${JSON.stringify(testCase)}`, () => {
9292
const { capacity, values } = testCase;
@@ -121,9 +121,9 @@ describe(DoubleStack.name, () => {
121121

122122
describe(`right stack`, () => {
123123
[
124-
{ capacity: null, values: [ 1 ] },
125-
{ capacity: null, values: [ 1, 2 ] },
126-
{ capacity: null, values: [ 1, 2, 3 ] },
124+
{ capacity: undefined, values: [ 1 ] },
125+
{ capacity: undefined, values: [ 1, 2 ] },
126+
{ capacity: undefined, values: [ 1, 2, 3 ] },
127127
].forEach(testCase => {
128128
it(`Should correctly implement pushRight(), popRight(), isEmpty* for ${JSON.stringify(testCase)}`, () => {
129129
const { capacity, values } = testCase;
@@ -144,7 +144,7 @@ describe(DoubleStack.name, () => {
144144
});
145145

146146
[
147-
{ capacity: null, values: [ ] },
147+
{ capacity: undefined, values: [ ] },
148148
].forEach(testCase => {
149149
it(`Should correctly implement pushRight(), popRight(), isEmpty* for ${JSON.stringify(testCase)}`, () => {
150150
const { capacity, values } = testCase;
@@ -232,9 +232,9 @@ describe(DoubleStack.name, () => {
232232

233233
describe(SingleStack.name, () => {
234234
[
235-
{ capacity: null, values: [ 1 ] },
236-
{ capacity: null, values: [ 1, 2 ] },
237-
{ capacity: null, values: [ 1, 2, 3 ] },
235+
{ capacity: undefined, values: [ 1 ] },
236+
{ capacity: undefined, values: [ 1, 2 ] },
237+
{ capacity: undefined, values: [ 1, 2, 3 ] },
238238
].forEach(testCase => {
239239
it(`Should correctly implement push(), pop(), isEmpty for ${JSON.stringify(testCase)}`, () => {
240240
const { capacity, values } = testCase;
@@ -254,7 +254,7 @@ describe(SingleStack.name, () => {
254254
});
255255

256256
[
257-
{ capacity: null, values: [ ] },
257+
{ capacity: undefined, values: [ ] },
258258
].forEach(testCase => {
259259
it(`Should correctly implement push(), pop(), isEmpty for ${JSON.stringify(testCase)}`, () => {
260260
const { capacity, values } = testCase;

__tests__/5-1-insert-m-into-n.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe(insertMintoN.name, () => {
1919
{ n: 1024, m: 19, i: 2, j: 6, expectedNumber: 1100 },
2020
{ n: 1198, m: 20, i: 2, j: 6, expectedNumber: 1234 },
2121
].forEach(({ n, m, i, j, expectedNumber }) => {
22-
const numberFrom = v => ((typeof v === 'number') ? v : Number.parseInt(v, 2)) >>> 0;
23-
const bitsFrom = v => (typeof v === 'string') ? v : v.toString(2);
22+
const numberFrom = (v: any) => ((typeof v === 'number') ? v : Number.parseInt(v, 2)) >>> 0;
23+
const bitsFrom = (v: any) => (typeof v === 'string') ? v : v.toString(2);
2424
const nNumber = numberFrom(n);
2525
const mNumber = numberFrom(m);
2626
const nBits = bitsFrom(n);

__tests__/8-2-robot-in-a-grid.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Grid,
55
} from '../src/cracking-the-coding-interview/8-recursion-and-dynamic-programming/8-2-robot-in-a-grid';
66

7-
const nullGrid: Grid = null;
7+
const nullGrid: Grid | undefined = undefined;
88

99
const gridWithSingleBlockedCell: Grid = [['x']];
1010

@@ -69,11 +69,11 @@ describe(`${findPathRecursively.name} & ${findPath.name}`, () => {
6969
const gridText = JSON.stringify(grid, null, 2);
7070

7171
it(`[Recursive] Should return "${path}" for grid\n${gridText}`, () => {
72-
expect(findPathRecursively(grid)).toEqual(expectedPath);
72+
expect(findPathRecursively(grid!)).toEqual(expectedPath);
7373
});
7474

7575
it(`[Non-recursive] Should return "${path}" for grid\n${gridText}`, () => {
76-
expect(findPath(grid)).toEqual(expectedPath);
76+
expect(findPath(grid!)).toEqual(expectedPath);
7777
});
7878
});
7979
});

0 commit comments

Comments
 (0)