(code: string, filename: string)
| 17 | || process.env.NODE_OPTIONS?.includes('--experimental-transform-types') |
| 18 | |
| 19 | export function transformCode(code: string, filename: string): string { |
| 20 | const ext = extname(filename.split('?')[0]) |
| 21 | const isTs = ext === '.ts' || ext === '.cts' || ext === '.mts' |
| 22 | if (!isTs) { |
| 23 | return code |
| 24 | } |
| 25 | if (!module.stripTypeScriptTypes) { |
| 26 | throw new Error(`Cannot parse '${filename}' because "module.stripTypeScriptTypes" is not supported. Module mocking requires Node.js 22.15 or higher. This is NOT a bug of Vitest.`) |
| 27 | } |
| 28 | return module.stripTypeScriptTypes(code, { mode: isTransform ? 'transform' : 'strip' }) |
| 29 | } |
| 30 | |
| 31 | const cachedFileExports = new Map<string, string[]>() |
| 32 |
no outgoing calls
no test coverage detected