From a1d052e29c12807e758be524549c9d23964a72b3 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 4 Jan 2024 17:43:14 +0100 Subject: [PATCH] Copy downleveled .d.ts files to dist/types/ --- build/downlevel-dts.js | 18 ++++++++++-------- es2018/package.json | 2 +- es6/package.json | 2 +- package.json | 2 +- ponyfill/es2018/package.json | 2 +- ponyfill/es6/package.json | 2 +- ponyfill/package.json | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/build/downlevel-dts.js b/build/downlevel-dts.js index b1d2bd0..fa5c264 100644 --- a/build/downlevel-dts.js +++ b/build/downlevel-dts.js @@ -5,20 +5,22 @@ const { Project, ts } = require('ts-morph'); const path = require('path'); const project = new Project(); -const inputDir = project.addDirectoryAtPath(path.join(__dirname, '../dist/types/')); +const inputDir = project.addDirectoryAtPath(path.join(__dirname, '../types/')); +const outputDir = project.createDirectory(path.join(__dirname, '../dist/types/')); // Create output directory -const ts36Dir = inputDir.createDirectory('ts3.6'); +const ts36Dir = outputDir.createDirectory('ts3.6'); project.saveSync(); // Down-level all *.d.ts files in input directory const files = inputDir.addSourceFilesAtPaths('*.d.ts'); -for (const f of files) { - // Create copy for TypeScript 3.6+ - f.copyToDirectory(ts36Dir, { overwrite: true }); - downlevelTS36(f); - downlevelTS34(f); - // Original file will be overwritten by down-leveled file when saved +for (const originalFile of files) { + // Create copy for TypeScript 3.6 and higher + originalFile.copyToDirectory(ts36Dir, { overwrite: true }); + // Downlevel and create copy for TypeScript 3.6 and lower + const downlevelFile = originalFile.copyToDirectory(outputDir, { overwrite: true }); + downlevelTS36(downlevelFile); + downlevelTS34(downlevelFile); } project.saveSync(); diff --git a/es2018/package.json b/es2018/package.json index b1ecfaf..878ab2d 100644 --- a/es2018/package.json +++ b/es2018/package.json @@ -3,5 +3,5 @@ "main": "../dist/polyfill.es2018", "browser": "../dist/polyfill.es2018.min.js", "module": "../dist/polyfill.es2018.mjs", - "types": "../types/polyfill.d.ts" + "types": "../dist/types/polyfill.d.ts" } diff --git a/es6/package.json b/es6/package.json index 7c90c45..ebdd02d 100644 --- a/es6/package.json +++ b/es6/package.json @@ -3,5 +3,5 @@ "main": "../dist/polyfill.es6", "browser": "../dist/polyfill.es6.min.js", "module": "../dist/polyfill.es6.mjs", - "types": "../types/polyfill.d.ts" + "types": "../dist/types/polyfill.d.ts" } diff --git a/package.json b/package.json index 8d8473f..f48a13c 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "dist/polyfill", "browser": "dist/polyfill.min.js", "module": "dist/polyfill.mjs", - "types": "types/polyfill.d.ts", + "types": "dist/types/polyfill.d.ts", "typesVersions": { ">=3.6": { "dist/types/*": [ diff --git a/ponyfill/es2018/package.json b/ponyfill/es2018/package.json index c2e92ed..3573f34 100644 --- a/ponyfill/es2018/package.json +++ b/ponyfill/es2018/package.json @@ -2,5 +2,5 @@ "name": "web-streams-ponyfill-es2018", "main": "../../dist/ponyfill.es2018", "module": "../../dist/ponyfill.es2018.mjs", - "types": "../../types/ponyfill.d.ts" + "types": "../../dist/types/ponyfill.d.ts" } diff --git a/ponyfill/es6/package.json b/ponyfill/es6/package.json index 46f2cc1..b629e6f 100644 --- a/ponyfill/es6/package.json +++ b/ponyfill/es6/package.json @@ -2,5 +2,5 @@ "name": "web-streams-ponyfill-es6", "main": "../../dist/ponyfill.es6", "module": "../../dist/ponyfill.es6.mjs", - "types": "../../types/ponyfill.d.ts" + "types": "../../dist/types/ponyfill.d.ts" } diff --git a/ponyfill/package.json b/ponyfill/package.json index a9d0bf6..310875e 100644 --- a/ponyfill/package.json +++ b/ponyfill/package.json @@ -2,5 +2,5 @@ "name": "web-streams-ponyfill", "main": "../dist/ponyfill", "module": "../dist/ponyfill.mjs", - "types": "../types/ponyfill.d.ts" + "types": "../dist/types/ponyfill.d.ts" }