From 37821075f9ba34db072d33b3f89a42effb4d9558 Mon Sep 17 00:00:00 2001 From: igalklebanov Date: Mon, 18 Nov 2024 01:50:38 +0200 Subject: [PATCH] fix jsdoc @ require-all-props. --- src/util/require-all-props.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/require-all-props.ts b/src/util/require-all-props.ts index 9d39ed2c3..e6de77547 100644 --- a/src/util/require-all-props.ts +++ b/src/util/require-all-props.ts @@ -25,14 +25,16 @@ type AllProps = T & { [P in keyof T]-?: unknown } * 1. Omit checked type - all checked properties will be expect as of type never * * ```ts - * const z: SomeType = requireAllProps({ propC: "no type will work" }); + * type SomeType = { propA: string; propB?: number; } + * // const z: SomeType = requireAllProps({ propC: "no type will work" }); // Property 'propA' is missing in type '{ propC: string; }' but required in type 'SomeType'. * ``` * * 2. Apply to spreaded object - there is no way how to check in compile time if spreaded object contains all properties * * ```ts + * type SomeType = { propA: string; propB?: number; } * const y: SomeType = { propA: "" }; // valid object according to SomeType declaration - * const x = requireAllProps( { ... y } ); + * // const x = requireAllProps({ ...y }); // Argument of type '{ propA: string; propB?: number; }' is not assignable to parameter of type 'AllProps'. * ``` * * @param obj object to check if all properties has been used