( text: string, options: NativeCompilerOptions, setupWorkspace: ((workpace: Workspace) => void) | undefined, filterIR: (ir: NativeCompilerIR.Base) => boolean, )
| 14 | } |
| 15 | |
| 16 | function compileAsIRString( |
| 17 | text: string, |
| 18 | options: NativeCompilerOptions, |
| 19 | setupWorkspace: ((workpace: Workspace) => void) | undefined, |
| 20 | filterIR: (ir: NativeCompilerIR.Base) => boolean, |
| 21 | ): string { |
| 22 | const workspace = new Workspace('/', false, undefined, { |
| 23 | target: ts.ScriptTarget.ESNext, |
| 24 | module: ts.ModuleKind.CommonJS, |
| 25 | lib: ['lib.es2015.d.ts'], |
| 26 | }); |
| 27 | |
| 28 | const filePath = 'file.ts'; |
| 29 | workspace.registerInMemoryFile(filePath, text); |
| 30 | workspace.addSourceFileAtPath(filePath); |
| 31 | if (setupWorkspace) { |
| 32 | setupWorkspace(workspace); |
| 33 | } |
| 34 | const irs = compileFile(workspace, true, options, filePath, filePath); |
| 35 | |
| 36 | const filteredIRs = irs.filter(filterIR); |
| 37 | return IRtoString(filteredIRs).trim(); |
| 38 | } |
| 39 | |
| 40 | function compileAsC( |
| 41 | text: string, |
no test coverage detected