(cwd: string)
| 713 | |
| 714 | // a TypeScript 7 project installs TypeScript 6 as `typescript-6` |
| 715 | export const loadTypeScript = (cwd: string): TypeScript => { |
| 716 | for (const from of [join(cwd, "package.json"), import.meta.url]) { |
| 717 | const require = createRequire(from) |
| 718 | for (const name of ["typescript", "typescript-6"]) { |
| 719 | let candidate: Partial<typeof ts> | undefined |
| 720 | try { |
| 721 | candidate = require(name) |
| 722 | } catch { |
| 723 | continue |
| 724 | } |
| 725 | if (/^(?:5\.(?:[5-9]|\d{2,})|6)\./.test(candidate?.version ?? "")) |
| 726 | return candidate as never |
| 727 | } |
| 728 | } |
| 729 | return throwError( |
| 730 | "ark declare and ark emit read the compiler API of TypeScript 5.5 to 6. Install `typescript`, or beside TypeScript 7, `typescript-6` as an alias: `npm i -D typescript-6@npm:typescript@6`" |
| 731 | ) |
| 732 | } |
| 733 | |
| 734 | export const parseConfig = ( |
| 735 | ts: TypeScript, |
no test coverage detected