@optique/run 1.0.0-dev.584 → 1.0.0-dev.588

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/run.d.cts CHANGED
@@ -226,11 +226,32 @@ interface RunOptions {
226
226
  */
227
227
  readonly contexts?: readonly SourceContext<unknown>[];
228
228
  }
229
+ /**
230
+ * Rejects context tuples that are statically known to be empty so those calls
231
+ * fall back to the synchronous no-context overloads.
232
+ */
229
233
  type RejectEmptyContexts<TContexts extends readonly SourceContext<unknown>[]> = TContexts extends readonly [] ? never : unknown;
234
+ /**
235
+ * Represents a context tuple that is statically known to contain at least one
236
+ * source context.
237
+ */
238
+ type NonEmptySourceContexts = readonly [SourceContext<unknown>, ...SourceContext<unknown>[]];
239
+ /**
240
+ * Rejects option shapes that may carry a non-empty `contexts` array so plain
241
+ * Program overloads do not bypass the context-aware overloads.
242
+ */
230
243
  type RejectContextfulOptions<TOptions> = TOptions extends {
231
244
  readonly contexts?: infer TContexts extends readonly SourceContext<unknown>[] | undefined;
232
245
  } ? [TContexts] extends [undefined | readonly []] ? unknown : never : unknown;
246
+ /**
247
+ * Rejects option shapes that introduce keys outside the public `RunOptions`
248
+ * contract, preserving excess-property checks for direct object literals.
249
+ */
233
250
  type RejectUnknownRunOptionKeys<TOptions> = [TOptions] extends [undefined] ? unknown : Exclude<keyof TOptions, keyof RunOptions> extends never ? unknown : never;
251
+ /**
252
+ * Accepts only values typed exactly as `RunOptions`, which are widened to the
253
+ * conservative fallback overloads because they may hide context presence.
254
+ */
234
255
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
235
256
  /**
236
257
  * Runs a command-line parser with automatic process integration.
@@ -297,10 +318,19 @@ type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOpt
297
318
  *
298
319
  * @since 0.11.0 Added support for {@link Program} objects.
299
320
  */
321
+ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends NonEmptySourceContexts>(parser: T, options: RunOptions & {
322
+ readonly contexts: TContexts;
323
+ } & ExtractRequiredOptions<TContexts, InferValue<T>>): Promise<InferValue<T>>;
300
324
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
301
325
  readonly contexts: TContexts;
302
- } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): Promise<InferValue<T>>;
303
- declare function run<M extends Mode, T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<M, T>, options: RunOptions & {
326
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): ModeValue<InferMode<T>, InferValue<T>> | Promise<InferValue<T>>;
327
+ declare function run<M extends Mode, T, const TContexts extends NonEmptySourceContexts>(program: Program<M, T>, options: RunOptions & {
328
+ readonly contexts: TContexts;
329
+ } & ExtractRequiredOptions<TContexts, T>): Promise<T>;
330
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"sync", T>, options: RunOptions & {
331
+ readonly contexts: TContexts;
332
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): T | Promise<T>;
333
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"async", T>, options: RunOptions & {
304
334
  readonly contexts: TContexts;
305
335
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
306
336
  declare function run<T, const TOptions extends RunOptions | undefined>(program: Program<"sync", T>, options?: TOptions & RejectContextfulOptions<TOptions> & RejectUnknownRunOptionKeys<TOptions>): T;
package/dist/run.d.ts CHANGED
@@ -226,11 +226,32 @@ interface RunOptions {
226
226
  */
227
227
  readonly contexts?: readonly SourceContext<unknown>[];
228
228
  }
229
+ /**
230
+ * Rejects context tuples that are statically known to be empty so those calls
231
+ * fall back to the synchronous no-context overloads.
232
+ */
229
233
  type RejectEmptyContexts<TContexts extends readonly SourceContext<unknown>[]> = TContexts extends readonly [] ? never : unknown;
234
+ /**
235
+ * Represents a context tuple that is statically known to contain at least one
236
+ * source context.
237
+ */
238
+ type NonEmptySourceContexts = readonly [SourceContext<unknown>, ...SourceContext<unknown>[]];
239
+ /**
240
+ * Rejects option shapes that may carry a non-empty `contexts` array so plain
241
+ * Program overloads do not bypass the context-aware overloads.
242
+ */
230
243
  type RejectContextfulOptions<TOptions> = TOptions extends {
231
244
  readonly contexts?: infer TContexts extends readonly SourceContext<unknown>[] | undefined;
232
245
  } ? [TContexts] extends [undefined | readonly []] ? unknown : never : unknown;
246
+ /**
247
+ * Rejects option shapes that introduce keys outside the public `RunOptions`
248
+ * contract, preserving excess-property checks for direct object literals.
249
+ */
233
250
  type RejectUnknownRunOptionKeys<TOptions> = [TOptions] extends [undefined] ? unknown : Exclude<keyof TOptions, keyof RunOptions> extends never ? unknown : never;
251
+ /**
252
+ * Accepts only values typed exactly as `RunOptions`, which are widened to the
253
+ * conservative fallback overloads because they may hide context presence.
254
+ */
234
255
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
235
256
  /**
236
257
  * Runs a command-line parser with automatic process integration.
@@ -297,10 +318,19 @@ type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOpt
297
318
  *
298
319
  * @since 0.11.0 Added support for {@link Program} objects.
299
320
  */
321
+ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends NonEmptySourceContexts>(parser: T, options: RunOptions & {
322
+ readonly contexts: TContexts;
323
+ } & ExtractRequiredOptions<TContexts, InferValue<T>>): Promise<InferValue<T>>;
300
324
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
301
325
  readonly contexts: TContexts;
302
- } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): Promise<InferValue<T>>;
303
- declare function run<M extends Mode, T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<M, T>, options: RunOptions & {
326
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): ModeValue<InferMode<T>, InferValue<T>> | Promise<InferValue<T>>;
327
+ declare function run<M extends Mode, T, const TContexts extends NonEmptySourceContexts>(program: Program<M, T>, options: RunOptions & {
328
+ readonly contexts: TContexts;
329
+ } & ExtractRequiredOptions<TContexts, T>): Promise<T>;
330
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"sync", T>, options: RunOptions & {
331
+ readonly contexts: TContexts;
332
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): T | Promise<T>;
333
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"async", T>, options: RunOptions & {
304
334
  readonly contexts: TContexts;
305
335
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
306
336
  declare function run<T, const TOptions extends RunOptions | undefined>(program: Program<"sync", T>, options?: TOptions & RejectContextfulOptions<TOptions> & RejectUnknownRunOptionKeys<TOptions>): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/run",
3
- "version": "1.0.0-dev.584+e5bde834",
3
+ "version": "1.0.0-dev.588+73f34b2e",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "sideEffects": false,
72
72
  "dependencies": {
73
- "@optique/core": "1.0.0-dev.584+e5bde834"
73
+ "@optique/core": "1.0.0-dev.588+73f34b2e"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",