Skip to content

Commit

Permalink
fix: fix get and getAll return types
Browse files Browse the repository at this point in the history
  • Loading branch information
ASafaeirad committed Apr 13, 2024
1 parent 1824b96 commit ae4385b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ export class Config<TSchema extends Record<string, Schema<any, any, boolean>>> {
return new ArraySchema(schema) as any;
}

public get<TKey extends ObjectPath<InferSchema<TSchema>>>(key: TKey) {
public get<TKey extends ObjectPath<InferSchema<TSchema>>>(
key: TKey,
): Prettify<GetPath<InferSchema<TSchema>, TKey>> {
const keys = key.split('.');
// @ts-expect-error error page
return keys.reduce((acc, k) => acc[k], this.value) as any as Prettify<
GetPath<InferSchema<TSchema>, TKey>
>;
}

public getAll() {
public getAll(): Prettify<InferSchema<TSchema>> {
return this.value as Prettify<InferSchema<TSchema>>;
}
}

0 comments on commit ae4385b

Please sign in to comment.