@optique/run 1.0.0-dev.586 → 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,12 +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
+ */
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 excess-property checks for direct object literals.
249
+ */
234
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
+ */
235
255
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
236
256
  /**
237
257
  * Runs a command-line parser with automatic process integration.
@@ -304,7 +324,13 @@ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts e
304
324
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
305
325
  readonly contexts: TContexts;
306
326
  } & 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 & {
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 & {
308
334
  readonly contexts: TContexts;
309
335
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
310
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,12 +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
+ */
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 excess-property checks for direct object literals.
249
+ */
234
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
+ */
235
255
  type AcceptExactRunOptions<TOptions> = [TOptions] extends [RunOptions] ? [RunOptions] extends [TOptions] ? unknown : never : never;
236
256
  /**
237
257
  * Runs a command-line parser with automatic process integration.
@@ -304,7 +324,13 @@ declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts e
304
324
  declare function run<T extends Parser<Mode, unknown, unknown>, const TContexts extends readonly SourceContext<unknown>[]>(parser: T, options: RunOptions & {
305
325
  readonly contexts: TContexts;
306
326
  } & 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 & {
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 & {
308
334
  readonly contexts: TContexts;
309
335
  } & RejectEmptyContexts<TContexts> & ExtractRequiredOptions<TContexts, T>): Promise<T>;
310
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.586+a66615c7",
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.586+a66615c7"
73
+ "@optique/core": "1.0.0-dev.588+73f34b2e"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",