@k8slens/injectable 26.2.0 → 26.2.2

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/index.d.ts +12 -6
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -858,6 +858,12 @@ export interface ConsumptionDi<Cons extends Consumption = never>
858
858
  injectMaybeWithMeta: ConsumptionInjectMaybeWithMeta2<Cons>;
859
859
  }
860
860
 
861
+ // `consumptions` is inferred as a readonly tuple, and `di` is narrowed to its
862
+ // elements. Inferred as the union of its elements instead, TypeScript would
863
+ // drop every token assignable to another one declared alongside it, as two
864
+ // tokens typed with `any` are, taking the dropped one's `.for()` descendants
865
+ // out of what `di` accepts.
866
+ //
861
867
  // With injectionToken: F is the injectable's actual factory (kept narrow so
862
868
  // `di.inject2(injectable)` returns the narrow factory), TF is the token's
863
869
  // factory contract. The `F extends TF` constraint verifies the implementation
@@ -865,11 +871,11 @@ export interface ConsumptionDi<Cons extends Consumption = never>
865
871
  export function getInjectable2<
866
872
  F extends TF,
867
873
  TF extends Factory,
868
- const Cons extends Consumption = never,
874
+ const Cons extends ReadonlyArray<Consumption> = [],
869
875
  >(options: {
870
876
  readonly id: string;
871
- readonly consumptions?: ReadonlyArray<Cons>;
872
- readonly instantiate: (di: ConsumptionDi<Cons>) => F;
877
+ readonly consumptions?: Cons;
878
+ readonly instantiate: (di: ConsumptionDi<Cons[number]>) => F;
873
879
  readonly injectionToken: InjectionTokenOf<Token2<TF, any, undefined, any>>;
874
880
  readonly transient?: boolean;
875
881
  readonly causesSideEffects?: boolean;
@@ -881,11 +887,11 @@ export function getInjectable2<
881
887
  // useInject / useInject2 still get precise parameter and return types.
882
888
  export function getInjectable2<
883
889
  F extends Factory,
884
- const Cons extends Consumption = never,
890
+ const Cons extends ReadonlyArray<Consumption> = [],
885
891
  >(options: {
886
892
  readonly id: string;
887
- readonly consumptions?: ReadonlyArray<Cons>;
888
- readonly instantiate: (di: ConsumptionDi<Cons>) => F;
893
+ readonly consumptions?: Cons;
894
+ readonly instantiate: (di: ConsumptionDi<Cons[number]>) => F;
889
895
  readonly transient?: boolean;
890
896
  readonly causesSideEffects?: boolean;
891
897
  readonly tags?: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@k8slens/injectable",
3
3
  "private": false,
4
- "version": "26.2.0",
4
+ "version": "26.2.2",
5
5
  "description": "A brutal dependency injection container",
6
6
  "lens": {
7
7
  "env": "agnostic",
@@ -37,7 +37,7 @@
37
37
  "devDependencies": {
38
38
  "@lensapp/code-style": "^1.2.0",
39
39
  "@lensapp/jest": "^7.2.0",
40
- "@k8slens/package-build": "^2.2.0",
40
+ "@k8slens/package-build": "^3.0.0",
41
41
  "tsd": "^0.29.0"
42
42
  },
43
43
  "publishConfig": {