Skip to content

Commit

Permalink
Use @template in JSDoc to document type parameters (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann authored Nov 19, 2024
1 parent 8c24d09 commit ee9e3e5
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/prop-types/any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any type. No built-in runtime validation is performed by default.
*
* Type parameter `T` can be used to restrict the type at compile time.
*
* @template T - can be used to restrict the type at compile time.
* @param validator - Optional function for runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const anyProp = <T = any>(
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any array. No further runtime validation is performed by default.
*
* Type parameter `T` can be used to restrict the type of the array items at compile time.
*
* @template T - can be used to restrict the type of the array items at compile time.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const arrayProp = <T = unknown>(
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ interface FunctionPropOptionsGenerator<T> {
/**
* Allows any function. No further runtime validation is performed by default.
*
* Type parameter `T` can be used to restrict the type to a specific function signature at compile time.
*
* @template T - can be used to restrict the type to a specific function signature at compile time.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const functionProp = <T extends Function>(
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/instanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { isInstanceOf } from '../validators';
/**
* Allows instances of the given constructor (validated at runtime and compile time).
*
* Type parameter `T` can be used to adjust the inferred type at compile time.
*
* @template T - can be used to adjust the inferred type at compile time.
* @param parent - The constructor to allow.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any number (validated at runtime and compile time).
*
* Type parameter `T` can be used to restrict the type at compile time with a union type.
*
* @template T - can be used to restrict the type at compile time with a union type.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const numberProp = <T extends number = number>(
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any object. No further runtime validation is performed by default.
*
* Type parameter `T` can be used to restrict the type at compile time.
*
* @template T - can be used to restrict the type at compile time.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const objectProp = <T = object>(
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/oneOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const getOneOfType = <T extends readonly unknown[]>(
/**
* Allows any of the specified allowed values (validated at runtime and compile time).
*
* Type parameter `T` can be used to adjust the inferred type at compile time, this is usually not necessary.
*
* @template T - can be used to adjust the inferred type at compile time, this is usually not necessary.
* @param allowedValues - The allowed values.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/oneOfObjectKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ type PlainObject = Record<number | string | symbol, unknown>;
/**
* Allows any of the keys of the specified object (validated at runtime and compile time).
*
* Type parameter `T` can be used to adjust the inferred type at compile time, this is usually not necessary.
*
* @template T - can be used to adjust the inferred type at compile time, this is usually not necessary.
* @param object - The object whose keys are allowed.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/oneOfTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any of the passed constructor types (validated at runtime).
*
* Type parameter `T` has to be used to adjust the type at compile time.
*
* @template T - has to be used to adjust the type at compile time.
* @param type - A single constructor or an array of constructors to allow.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/prop-types/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type { Validator } from '../validators';
/**
* Allows any string. No further runtime validation is performed by default.
*
* Type parameter `T` can be used to restrict the type at compile time with a union type.
*
* @template T - can be used to restrict the type at compile time with a union type.
* @param validator - Optional function for further runtime validation; should return `undefined` if valid, or an error string if invalid.
*/
export const stringProp = <T extends string = string>(
Expand Down

0 comments on commit ee9e3e5

Please sign in to comment.