Skip to content

Commit aba2018

Browse files
author
Hannia Valera
committed
widen execution.jobs type to support string in TestPreset
1 parent 3778342 commit aba2018

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ class CMakeProjectWrapper implements api.Project {
9898

9999
get testPreset() {
100100
logApiTelemetry('getTestPreset');
101-
return this.project.testPreset ?? undefined;
101+
// Cast: internal TestPreset widens execution.jobs to number | string (v11+),
102+
// but the external API still exposes the narrower number type.
103+
return this.project.testPreset as api.TestPreset | null ?? undefined;
102104
}
103105

104106
get packagePreset() {

src/presets/preset.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,15 @@ export interface TestPresetPrivate {
256256
__generator?: string; // Getting this from the config preset
257257
}
258258

259-
export interface TestPreset extends api.TestPreset, TestPresetPrivate, PresetPrivate {}
259+
// v11+: execution.jobs can be an empty string (--parallel with no value).
260+
// Widen the type from the API's number to number | string.
261+
export interface TestExecutionOptions extends Omit<api.ExecutionOptions, 'jobs'> {
262+
jobs?: number | string;
263+
}
264+
265+
export interface TestPreset extends Omit<api.TestPreset, 'execution'>, TestPresetPrivate, PresetPrivate {
266+
execution?: TestExecutionOptions;
267+
}
260268

261269
export interface PackagePresetPrivate {
262270
__binaryDir?: string; // Getting this from the config preset
@@ -2299,12 +2307,10 @@ export function testArgs(preset: TestPreset): string[] {
22992307
preset.execution.enableFailover && result.push('-F');
23002308
if (preset.execution.jobs !== undefined) {
23012309
// v11+: jobs can be an empty string meaning --parallel with no value (auto-detect).
2302-
// The API type says number, but JSON parsing may produce a string at runtime.
2303-
const jobsValue = preset.execution.jobs as number | string;
2304-
if (typeof jobsValue === 'string' && jobsValue.length === 0) {
2310+
if (preset.execution.jobs === '') {
23052311
result.push('--parallel');
23062312
} else {
2307-
result.push('--parallel', jobsValue.toString());
2313+
result.push('--parallel', preset.execution.jobs.toString());
23082314
}
23092315
}
23102316
preset.execution.resourceSpecFile && result.push('--resource-spec-file', preset.execution.resourceSpecFile);

0 commit comments

Comments
 (0)