@optique/run 1.0.0-dev.586 → 1.0.0-dev.590

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,12 +226,33 @@ 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
+ */
230
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
+ */
231
243
  type RejectContextfulOptions<TOptions> = TOptions extends {
232
244
  readonly contexts?: infer TContexts extends readonly SourceContext<unknown>[] | undefined;
233
245
  } ? [TContexts] extends [undefined | readonly []] ? unknown : never : unknown;
246
+ /**
247
+ * Rejects option shapes that introduce keys outside the public `RunOptions`
248
+ * contract, preserving typo detection for direct object literals and wider
249
+ * option variables.
250
+ */
234
251
  type RejectUnknownRunOptionKeys<TOptions> = [TOptions] extends [undefined] ? unknown : Exclude<keyof TOptions, keyof RunOptions> extends never ? unknown : never;
252
+ /**
253
+ * Accepts only values typed exactly as `RunOptions`, which are widened to the
254
+ * conservative fallback overloads because they may hide context presence.
255
+ */
235
256
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
236
257
  /**
237
258
  * Runs a command-line parser with automatic process integration.
@@ -304,7 +325,13 @@ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts e
304
325
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
305
326
  readonly contexts: TContexts;
306
327
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): ModeValue<InferMode<T>, InferValue<T>> | Promise<InferValue<T>>;
307
- declare function run<M extends Mode, T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<M, T>, options: RunOptions & {
328
+ declare function run<M extends Mode, T, const TContexts extends NonEmptySourceContexts>(program: Program<M, T>, options: RunOptions & {
329
+ readonly contexts: TContexts;
330
+ } & ExtractRequiredOptions<TContexts, T>): Promise<T>;
331
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"sync", T>, options: RunOptions & {
332
+ readonly contexts: TContexts;
333
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): T | Promise<T>;
334
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"async", T>, options: RunOptions & {
308
335
  readonly contexts: TContexts;
309
336
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
310
337
  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,12 +226,33 @@ 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
+ */
230
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
+ */
231
243
  type RejectContextfulOptions<TOptions> = TOptions extends {
232
244
  readonly contexts?: infer TContexts extends readonly SourceContext<unknown>[] | undefined;
233
245
  } ? [TContexts] extends [undefined | readonly []] ? unknown : never : unknown;
246
+ /**
247
+ * Rejects option shapes that introduce keys outside the public `RunOptions`
248
+ * contract, preserving typo detection for direct object literals and wider
249
+ * option variables.
250
+ */
234
251
  type RejectUnknownRunOptionKeys<TOptions> = [TOptions] extends [undefined] ? unknown : Exclude<keyof TOptions, keyof RunOptions> extends never ? unknown : never;
252
+ /**
253
+ * Accepts only values typed exactly as `RunOptions`, which are widened to the
254
+ * conservative fallback overloads because they may hide context presence.
255
+ */
235
256
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
236
257
  /**
237
258
  * Runs a command-line parser with automatic process integration.
@@ -304,7 +325,13 @@ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts e
304
325
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
305
326
  readonly contexts: TContexts;
306
327
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, InferValue<T>>): ModeValue<InferMode<T>, InferValue<T>> | Promise<InferValue<T>>;
307
- declare function run<M extends Mode, T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<M, T>, options: RunOptions & {
328
+ declare function run<M extends Mode, T, const TContexts extends NonEmptySourceContexts>(program: Program<M, T>, options: RunOptions & {
329
+ readonly contexts: TContexts;
330
+ } & ExtractRequiredOptions<TContexts, T>): Promise<T>;
331
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"sync", T>, options: RunOptions & {
332
+ readonly contexts: TContexts;
333
+ } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): T | Promise<T>;
334
+ declare function run<T, const TContexts extends readonly SourceContext<unknown>[]>(program: Program<"async", T>, options: RunOptions & {
308
335
  readonly contexts: TContexts;
309
336
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
310
337
  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.586+a66615c7",
3
+ "version": "1.0.0-dev.590+558b31b5",
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.586+a66615c7"
73
+ "@optique/core": "1.0.0-dev.590+558b31b5"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",