inwire 2.3.0 → 2.3.1

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.
Files changed (2) hide show
  1. package/dist/index.d.mts +18 -6
  2. package/package.json +3 -3
package/dist/index.d.mts CHANGED
@@ -373,6 +373,12 @@ interface ContainerWarning {
373
373
  }
374
374
  //#endregion
375
375
  //#region src/application/container-builder.d.ts
376
+ /**
377
+ * `T` with the keys of `U` overridden by `U` (no duplicate-key intersection).
378
+ * Required to avoid `A & A → never` when classes have private members and the
379
+ * same key is declared in both `T` and `U` (e.g. global AppDeps + module add).
380
+ */
381
+ type Override<T, U> = Omit<T, keyof U> & U;
376
382
  /**
377
383
  * Fluent builder that constructs a typed DI container incrementally.
378
384
  *
@@ -391,16 +397,22 @@ declare class ContainerBuilder<TContract extends Record<string, any> = Record<st
391
397
  * Convention: `typeof value === 'function'` → factory. Otherwise → instance (wrapped in `() => value`).
392
398
  * To register a function as a value: `add('fn', () => myFunction)`.
393
399
  */
394
- add<K extends string & keyof TContract, V extends TContract[K]>(key: K & (K extends (typeof RESERVED_KEYS)[number] ? never : K), factoryOrInstance: ((c: TBuilt) => V) | (V & (V extends Function ? never : V))): ContainerBuilder<TContract, TBuilt & Record<K, V>>;
400
+ add<K extends string & keyof TContract, V extends TContract[K]>(key: K & (K extends (typeof RESERVED_KEYS)[number] ? never : K), factoryOrInstance: ((c: TBuilt) => V) | (V & (V extends Function ? never : V))): ContainerBuilder<TContract, Override<TBuilt, Record<K, V>>>;
395
401
  /**
396
402
  * Registers a transient dependency (new instance on every access).
397
403
  */
398
- addTransient<K extends string & keyof TContract, V extends TContract[K]>(key: K & (K extends (typeof RESERVED_KEYS)[number] ? never : K), factory: (c: TBuilt) => V): ContainerBuilder<TContract, TBuilt & Record<K, V>>;
404
+ addTransient<K extends string & keyof TContract, V extends TContract[K]>(key: K & (K extends (typeof RESERVED_KEYS)[number] ? never : K), factory: (c: TBuilt) => V): ContainerBuilder<TContract, Override<TBuilt, Record<K, V>>>;
399
405
  /**
400
406
  * Applies a module — a function that chains `.add()` calls on this builder.
401
- * `c` in the module's factories is fully typed with all previously registered deps.
407
+ *
408
+ * `TDepsM` (the module's expected prereqs) is inferred independently from the
409
+ * builder's current `TBuilt`. Prereq satisfaction is NOT enforced at the type
410
+ * level on purpose: in global mode (`defineModule()` typed against `AppDeps`)
411
+ * the prereq surface is the full app, never the partial builder state. The
412
+ * runtime guarantees correctness via `ProviderNotFoundError` if a key is
413
+ * missing at resolution time.
402
414
  */
403
- addModule<TNew extends Record<string, any>>(module: (builder: ContainerBuilder<TContract, TBuilt>) => ContainerBuilder<TContract, TNew>): ContainerBuilder<TContract, TBuilt & TNew>;
415
+ addModule<TDepsM extends Record<string, any>, TNew extends Record<string, any>>(module: (builder: ContainerBuilder<TContract, TDepsM>) => ContainerBuilder<TContract, TNew>): ContainerBuilder<TContract, Override<TBuilt, TNew>>;
404
416
  /**
405
417
  * Merges a standalone builder into this one. All factories of `other` are copied.
406
418
  * The accumulated type becomes `TBuilt & TOther`, so subsequent factories can
@@ -415,7 +427,7 @@ declare class ContainerBuilder<TContract extends Record<string, any> = Record<st
415
427
  * Cross-builder dependencies are resolved at build time. Reserved keys throw.
416
428
  * Duplicate keys override silently — same semantics as `.add()` over an existing key.
417
429
  */
418
- merge<TOther extends Record<string, unknown>>(other: ContainerBuilder<Record<string, unknown>, TOther>): ContainerBuilder<TContract, TBuilt & TOther>;
430
+ merge<TOther extends Record<string, unknown>>(other: ContainerBuilder<Record<string, unknown>, TOther>): ContainerBuilder<TContract, Override<TBuilt, TOther>>;
419
431
  /**
420
432
  * Returns the accumulated factories as a plain record.
421
433
  * @internal Used by `module()` on the container and `merge()` on builders.
@@ -567,7 +579,7 @@ declare function detectDuplicateKeys(...modules: Record<string, unknown>[]): str
567
579
  * app.requestId; // 'def-456' (different!)
568
580
  * ```
569
581
  */
570
- declare function transient<T>(factory: Factory<T>): Factory<T>;
582
+ declare function transient<T, C = unknown>(factory: (container: C) => T): (container: C) => T;
571
583
  //#endregion
572
584
  export { type AppDeps, AsyncInitErrorWarning, CircularDependencyError, type Container, ContainerBuilder, ContainerConfigError, ContainerError, type ContainerGraph, type ContainerHealth, type ContainerWarning, type Factory, FactoryError, type IContainer, type InferModuleBuilt, type InferModuleDeps, type Module, type OnDestroy, type OnInit, type ProviderInfo, ProviderNotFoundError, ReservedKeyError, ScopeMismatchWarning, type ScopeOptions, UndefinedReturnError, container, defineModule, detectDuplicateKeys, transient };
573
585
  //# sourceMappingURL=index.d.mts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inwire",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Zero-ceremony dependency injection for TypeScript. Full inference, no decorators, no tokens. Built-in introspection for AI tooling.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -20,12 +20,12 @@
20
20
  "test": "vitest run",
21
21
  "test:watch": "vitest",
22
22
  "test:coverage": "vitest run --coverage",
23
- "typecheck": "tsc --noEmit",
23
+ "typecheck": "tsc --noEmit && tsc --noEmit -p examples/tsconfig.json",
24
24
  "lint": "biome check",
25
25
  "lint:fix": "biome check --fix",
26
26
  "format": "biome format --write",
27
27
  "format:check": "biome format",
28
- "check": "biome check && tsc --noEmit",
28
+ "check": "biome check && pnpm typecheck",
29
29
  "example:web": "tsx examples/01-web-service.ts",
30
30
  "example:test": "tsx examples/02-modular-testing.ts",
31
31
  "example:plugin": "tsx examples/03-plugin-system.ts",