| 14 | * compiles a test file using the specified tsc binary which imports all entry-points. |
| 15 | */ |
| 16 | export async function runTypeScriptCompatibilityTest(tscBinPath) { |
| 17 | return new Promise((resolve, reject) => { |
| 18 | const tscArgs = [ |
| 19 | '--strict', |
| 20 | // Disables automatic type resolution. In non-sandbox environments, the node modules |
| 21 | // are accessible and types could end up as part of the program. |
| 22 | '--types', |
| 23 | '--lib', |
| 24 | 'es2015,dom', |
| 25 | testFilePath, |
| 26 | '--moduleResolution', |
| 27 | 'bundler', |
| 28 | '--module', |
| 29 | 'es2022', |
| 30 | ]; |
| 31 | // Run `tsc` to compile the project. The stdout/stderr output is inherited, so that |
| 32 | // warnings and errors are printed to the console. |
| 33 | const tscProcess = fork(tscBinPath, tscArgs, {stdio: 'inherit'}); |
| 34 | |
| 35 | tscProcess.on('exit', exitCode => { |
| 36 | exitCode === 0 ? resolve() : reject(); |
| 37 | }); |
| 38 | }); |
| 39 | } |