Skip to content

Commit

Permalink
Merge pull request #14968 from forivall/forivall/improve-goto-definition
Browse files Browse the repository at this point in the history
types: improve goto definition for inferred schema definitions
  • Loading branch information
vkarpov15 authored Oct 20, 2024
2 parents 830b010 + 5c003f8 commit 925327f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions types/inferschematype.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ type RequiredPathKeys<T, TypeKey extends string = DefaultTypeKey> = {
* @param {TypeKey} TypeKey A generic of literal string type."Refers to the property used for path type definition".
* @returns a record contains required paths with the corresponding type.
*/
type RequiredPaths<T, TypeKey extends string = DefaultTypeKey> = {
[K in RequiredPathKeys<T, TypeKey>]: T[K];
};
type RequiredPaths<T, TypeKey extends string = DefaultTypeKey> = Pick<
{ -readonly [K in keyof T]: T[K] },
RequiredPathKeys<T, TypeKey>
>;

/**
* @summary A Utility to obtain schema's optional path keys.
Expand All @@ -166,9 +167,10 @@ type OptionalPathKeys<T, TypeKey extends string = DefaultTypeKey> = {
* @param {TypeKey} TypeKey A generic of literal string type."Refers to the property used for path type definition".
* @returns a record contains optional paths with the corresponding type.
*/
type OptionalPaths<T, TypeKey extends string = DefaultTypeKey> = {
[K in OptionalPathKeys<T, TypeKey>]?: T[K];
};
type OptionalPaths<T, TypeKey extends string = DefaultTypeKey> = Pick<
{ -readonly [K in keyof T]?: T[K] },
OptionalPathKeys<T, TypeKey>
>;

/**
* @summary Allows users to optionally choose their own type for a schema field for stronger typing.
Expand Down

0 comments on commit 925327f

Please sign in to comment.