@@ -47,7 +47,7 @@ export async function initializeParsers(): Promise<Parsers> {
47
47
}
48
48
49
49
export function getFirstFunction ( tree : Parser . Tree ) : Parser . SyntaxNode | null {
50
- let functionNode : Parser . SyntaxNode = null ;
50
+ let functionNode : Parser . SyntaxNode | null = null ;
51
51
const cursor = tree . walk ( ) ;
52
52
53
53
const funcTypes = [
@@ -93,7 +93,7 @@ export interface TestResults {
93
93
export function runTest ( record : TestFuncRecord ) : TestResults [ ] {
94
94
const tree = parsers [ record . language ] . parse ( record . code ) ;
95
95
const testFunc : TestFunction = {
96
- function : getFirstFunction ( tree ) ,
96
+ function : getFirstFunction ( tree ) as Parser . SyntaxNode ,
97
97
language : record . language ,
98
98
name : record . name ,
99
99
reqs : record . reqs ,
@@ -125,8 +125,8 @@ export function processRecord(
125
125
) : { dot ?: string ; ast : string ; svg ?: string ; error ?: Error } {
126
126
const { trim, simplify, verbose, flatSwitch } = options ;
127
127
const tree = parsers [ record . language ] . parse ( record . code ) ;
128
- const functionSyntax = getFirstFunction ( tree ) ;
129
128
const builder = newCFGBuilder ( record . language , { flatSwitch } ) ;
129
+ const functionSyntax = getFirstFunction ( tree ) as Parser . SyntaxNode ;
130
130
131
131
const ast = functionSyntax . toString ( ) ;
132
132
@@ -135,7 +135,10 @@ export function processRecord(
135
135
try {
136
136
cfg = builder . buildCFG ( functionSyntax ) ;
137
137
} catch ( error ) {
138
- return { ast, error } ;
138
+ return {
139
+ ast,
140
+ error : error instanceof Error ? error : new Error ( `${ error } ` ) ,
141
+ } ;
139
142
}
140
143
141
144
if ( ! cfg ) return { ast } ;
0 commit comments