@next-box/appsettings 0.0.5 → 0.0.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@next-box/appsettings",
3
3
  "description": "A configuration management library for TypeScript applications, inspired by .NET’s appsettings.json.",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "author": "miami-man",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/next-box",
@@ -3,9 +3,11 @@ import { type SettingSectionPath } from '#types/Config.types.ts';
3
3
  import { type AppSettingsSchema } from '../index.ts';
4
4
  import { useAppSettingsContext } from './useAppSettingsContext.ts';
5
5
 
6
- export function useAppSettings<P extends SettingSectionPath<AppSettingsSchema>>(
7
- path: P,
8
- ): Get<AppSettingsSchema, P> | undefined;
6
+ export function useAppSettings<
7
+ P extends SettingSectionPath<{
8
+ [K in keyof AppSettingsSchema]: AppSettingsSchema[K];
9
+ }>,
10
+ >(path: P): Get<AppSettingsSchema, P> | undefined;
9
11
 
10
12
  export function useAppSettings<T extends object, P extends SettingSectionPath<T>>(path: P): Get<T, P> | undefined;
11
13
 
@@ -17,10 +17,11 @@ export type SettingPath<T extends object, Depth extends number = 5> = Depth exte
17
17
  export type SettingSectionPath<T extends object, Depth extends number = 5> = Depth extends 0
18
18
  ? never
19
19
  : {
20
- [K in Exclude<Extract<keyof T, string>, '__appSettingsSchema'>]: T[K] extends Primitive | readonly Primitive[]
20
+ [K in Exclude<Extract<keyof T, string>, '__appSettingsSchema'>]: NonNullable<T[K]> extends
21
+ Primitive | readonly Primitive[]
21
22
  ? never
22
- : T[K] extends object
23
- ? K | `${K}.${SettingSectionPath<T[K], PreviousDepth[Depth]>}`
23
+ : NonNullable<T[K]> extends object
24
+ ? K | `${K}.${SettingSectionPath<NonNullable<T[K]>, PreviousDepth[Depth]>}`
24
25
  : never;
25
26
  }[Exclude<Extract<keyof T, string>, '__appSettingsSchema'>];
26
27