Skip to content

Commit 1048a05

Browse files
committed
Fix all tsc error in utils.ts
1 parent f29f07a commit 1048a05

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/frontend/src/lib/utils.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function initializeParsers(): Promise<Parsers> {
4747
}
4848

4949
export function getFirstFunction(tree: Parser.Tree): Parser.SyntaxNode | null {
50-
let functionNode: Parser.SyntaxNode = null;
50+
let functionNode: Parser.SyntaxNode | null = null;
5151
const cursor = tree.walk();
5252

5353
const funcTypes = [
@@ -93,7 +93,7 @@ export interface TestResults {
9393
export function runTest(record: TestFuncRecord): TestResults[] {
9494
const tree = parsers[record.language].parse(record.code);
9595
const testFunc: TestFunction = {
96-
function: getFirstFunction(tree),
96+
function: getFirstFunction(tree) as Parser.SyntaxNode,
9797
language: record.language,
9898
name: record.name,
9999
reqs: record.reqs,
@@ -125,8 +125,8 @@ export function processRecord(
125125
): { dot?: string; ast: string; svg?: string; error?: Error } {
126126
const { trim, simplify, verbose, flatSwitch } = options;
127127
const tree = parsers[record.language].parse(record.code);
128-
const functionSyntax = getFirstFunction(tree);
129128
const builder = newCFGBuilder(record.language, { flatSwitch });
129+
const functionSyntax = getFirstFunction(tree) as Parser.SyntaxNode;
130130

131131
const ast = functionSyntax.toString();
132132

@@ -135,7 +135,10 @@ export function processRecord(
135135
try {
136136
cfg = builder.buildCFG(functionSyntax);
137137
} catch (error) {
138-
return { ast, error };
138+
return {
139+
ast,
140+
error: error instanceof Error ? error : new Error(`${error}`),
141+
};
139142
}
140143

141144
if (!cfg) return { ast };

tsconfig.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"compilerOptions": {
3-
"lib": [
4-
"ESNext"
5-
],
3+
"lib": ["ESNext"],
64
"target": "ESNext",
75
"module": "ESNext",
86
"moduleDetection": "force",
@@ -19,12 +17,8 @@
1917
"noFallthroughCasesInSwitch": true,
2018
"forceConsistentCasingInFileNames": true,
2119
"paths": {
22-
"vscode": [
23-
"./mocks/vscode.ts"
24-
]
25-
},
20+
"vscode": ["./mocks/vscode.ts"]
21+
}
2622
},
27-
"exclude": [
28-
"./webview-content"
29-
]
30-
}
23+
"exclude": ["./webview-content"]
24+
}

0 commit comments

Comments
 (0)