Skip to content

Commit 648f53f

Browse files
committed
Build types refactoring
1 parent 0ab39ea commit 648f53f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

scripts/build-types/index.mjs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,16 @@ const imports = {
2828
};
2929
let outputFiles = {};
3030

31-
function addType(filePath, template, options) {
31+
function addType(tsVersion, subset, template, options) {
32+
const filePath = buildFilePath(tsVersion, subset);
33+
if (!outputFiles[filePath]) outputFiles[filePath] = '';
3234
const entryWithTypes = template(options);
3335
outputFiles[filePath] += `${ entryWithTypes.types }${ entryWithTypes.types ? '\n' : '' }`;
3436
}
3537

3638
function addEntryTypes(tsVersion, template, options) {
37-
const indexPath = buildFilePath(tsVersion, 'index');
38-
if (!outputFiles[indexPath]) outputFiles[indexPath] = '';
39-
const optionsGlobal = { ...options, packageName: PACKAGE_NAME };
40-
addType(indexPath, template, optionsGlobal);
41-
42-
const purePath = buildFilePath(tsVersion, 'pure');
43-
if (!outputFiles[purePath]) outputFiles[purePath] = '';
44-
const optionsPure = { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX };
45-
addType(purePath, template, optionsPure);
39+
addType(tsVersion, 'index', template, { ...options, packageName: PACKAGE_NAME });
40+
addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX });
4641
}
4742

4843
async function buildType(entry, options) {

0 commit comments

Comments
 (0)