Skip to content

Commit

Permalink
Copy downleveled .d.ts files to dist/types/
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Jan 4, 2024
1 parent 3c324ee commit a1d052e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions build/downlevel-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion es2018/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion es6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*": [
Expand Down
2 changes: 1 addition & 1 deletion ponyfill/es2018/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion ponyfill/es6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion ponyfill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit a1d052e

Please sign in to comment.