/
githubmirror
/
DefinitelyTyped
Обзор
Документация
Войти
/
githubmirror
/
DefinitelyTyped
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scripts/try-node16.js
42 строки
1 KB
Andrew Branch
Make all packages work with `esModuleInterop` (default `true` in TS 6.0) (#73954)
24 окт 2025, 06:58
Не верифицирован
24 окт 2025, 06:58
9a370b0
Код
Авторство
О чём код?
import { AllPackages, getDefinitelyTyped } from "@definitelytyped/definitions-parser"; import { loggerWithErrors } from "@definitelytyped/utils"; import cp from "child_process"; import fs from "fs"; import path from "path"; import url from "url"; const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); const repoRoot = path.join(__dirname, ".."); const dtFS = await getDefinitelyTyped({ definitelyTypedPath: repoRoot, progress: false, }, loggerWithErrors()[0]); const allPackages = AllPackages.fromFS(dtFS); for (const pkg of await allPackages.allTypings()) { console.log(`Trying ${pkg.subDirectoryPath}...`); const tsconfigPath = path.join(repoRoot, "types", pkg.subDirectoryPath, "tsconfig.json"); const tsconfigString = fs.readFileSync(tsconfigPath, "utf-8"); const tsconfig = JSON.parse(tsconfigString); if (tsconfig.compilerOptions.module === "node16") { continue; } const newTsconfig = JSON.parse(tsconfigString); newTsconfig.compilerOptions.module = "node16"; fs.writeFileSync(tsconfigPath, JSON.stringify(newTsconfig, undefined, 4) + "\n", "utf-8"); try { cp.execFileSync( path.join(repoRoot, "node_modules/.bin/tsc"), ["-p", tsconfigPath, "--noEmit"], { stdio: "ignore" }, ); } catch { fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, undefined, 4) + "\n", "utf-8"); console.log(tsconfigPath); } }