Skip to content

Commit 5908b83

Browse files
committed
Types for configurator
1 parent d54c5f7 commit 5908b83

File tree

7 files changed

+37
-2
lines changed

7 files changed

+37
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare function configurator(options: Record<PropertyKey, any>): void;

scripts/build-entries-and-types/build-types.mjs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { features, proposals } from './entries-definitions.mjs';
2-
import { $path, $proposal, $typeDummy } from './templates.mjs';
2+
import { $namespace, $path, $proposal, $typeDummy } from './templates.mjs';
33
import { modules as AllModules } from '@core-js/compat/src/data.mjs';
44
import { getModulesMetadata } from './get-dependencies.mjs';
55
import { expandModules, modulesToStage } from './helpers.mjs';
@@ -25,6 +25,7 @@ const imports = {
2525
full: new Set(),
2626
pure: new Set(),
2727
index: new Set(),
28+
configurator: new Set(),
2829
};
2930
let outputFiles = {};
3031

@@ -42,6 +43,9 @@ function addType(tsVersion, subset, template, options) {
4243
function addEntryTypes(tsVersion, template, options) {
4344
addType(tsVersion, 'index', template, { ...options, packageName: PACKAGE_NAME });
4445
addType(tsVersion, 'pure', template, { ...options, packageName: PACKAGE_NAME_PURE, prefix: TYPE_PREFIX });
46+
if (options.exportForSubset) {
47+
addType(tsVersion, options.subset, template, { ...options, packageName: PACKAGE_NAME });
48+
}
4549
}
4650

4751
async function buildType(entry, options) {
@@ -105,7 +109,7 @@ async function buildType(entry, options) {
105109
}
106110
imports.pure.add(path.join('pure', customType));
107111
}
108-
options = { ...options, modules, level, entry, types };
112+
options = { ...options, modules, level, entry, types, subset };
109113

110114
addEntryTypes(tsVersion, template, options);
111115
if (!entry.endsWith('/')) { // add alias with .js ending
@@ -226,6 +230,16 @@ async function buildTypesForTSVersion(tsVersion) {
226230
await buildType('full/index', { template: $path, modules: AllModules, tsVersion });
227231
await buildType('index', { template: $path, modules: ActualModules, tsVersion });
228232

233+
await buildType('configurator', {
234+
entryFromNamespace: 'configurator',
235+
template: $namespace,
236+
modules: ['configurator'],
237+
name: 'configurator',
238+
tsVersion,
239+
types: ['configurator'],
240+
exportForSubset: true,
241+
});
242+
229243
await prependImports(tsVersion);
230244
await saveOutputFiles();
231245
}
@@ -293,6 +307,7 @@ const namespaces = {
293307
pure: { isDir: false },
294308
proposals: { isDir: true },
295309
index: { isDir: false },
310+
configurator: { isDir: false },
296311
};
297312
await buildPackageJson(TS_VERSION_BREAKPOINTS, namespaces);
298313

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
configurator({ something: 'value' });
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"include": ["./configurator.ts"],
4+
"compilerOptions": {
5+
"types": [
6+
"@core-js/types"
7+
]
8+
}
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import '@core-js/types/configurator';
2+
3+
configurator({ something: 'value' });
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"include": ["./configurator.ts"]
4+
}

tests/type-definitions/runner.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ tasks.push(
166166
{ args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/proposals/tsconfig.json'] },
167167
{ args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/global/tsconfig.json'] },
168168
{ args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/pure/tsconfig.json'] },
169+
{ args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/global/tsconfig.json'] },
170+
{ args: ['-p', 'typescript@5.9', 'tsc', '-p', 'entries/configurator/import/tsconfig.json'] },
169171
);
170172

171173
let envs;

0 commit comments

Comments
 (0)