| 38 | (strict ? parseStrict : parse)(str, acornOptions) as unknown as Program; |
| 39 | |
| 40 | export const parseSource: (str: string) => (Statement & AcornNode)[] = str => { |
| 41 | const parsed = parseProgram(str) as unknown as { |
| 42 | body: (Statement & AcornNode)[]; |
| 43 | }; |
| 44 | |
| 45 | // acorn-loose adds a "dummy" identifier to function expressions parsing |
| 46 | // as a program, which creates an invalid name. But this isn't actually necesary. |
| 47 | for (const stmt of parsed.body) { |
| 48 | if (stmt.type === 'FunctionDeclaration' && stmt.id && isDummy(stmt.id)) { |
| 49 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 50 | (stmt as any).id = null; |
| 51 | } |
| 52 | } |
| 53 | return parsed.body; |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * function (params) { code } => function (params) { catchAndReturnErrors?(code) } |
no test coverage detected