Options
All
  • Public
  • Public/Protected
  • All
Menu

TypeDoc Example

Index

Collection Functions

lodashSortBy

  • lodashSortBy<T>(collection: undefined | null | List<T>, ...iteratees: Many<ListIteratee<T>>[]): T[]
  • lodashSortBy<T>(collection: undefined | null | T, ...iteratees: Many<ObjectIteratee<T>>[]): T[keyof T][]
  • Creates an array of elements, sorted in ascending order by the results of running each element in a collection through each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratees are invoked with one argument: (value).

    example

    var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 42 }, { 'user': 'barney', 'age': 34 } ];

    _.sortBy(users, function(o) { return o.user; }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

    _.sortBy(users, ['user', 'age']); // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]

    _.sortBy(users, 'user', function(o) { return Math.floor(o.age / 10); }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

    Type parameters

    • T

    Parameters

    • collection: undefined | null | List<T>

      The collection to iterate over.

    • Rest ...iteratees: Many<ListIteratee<T>>[]

    Returns T[]

    Returns the new sorted array.

  • see

    _.sortBy

    Type parameters

    • T: object

    Parameters

    • collection: undefined | null | T
    • Rest ...iteratees: Many<ObjectIteratee<T>>[]

    Returns T[keyof T][]

Other Functions

sqrt

  • sqrt(x: number): number
  • Calculates the square root of a number.

    Parameters

    • x: number

      the number to calculate the root of.

    Returns number

    the square root if x is non-negative or NaN if x is negative.

Const sqrtArrowFunction

  • sqrtArrowFunction(x: number): number
  • Calculates the square root of a number.

    sqrtArrowFunction is defined using a variable declaration:

    export const sqrtArrowFunction = (x: number): number => Math.sqrt(x);
    

    TypeDoc is smart and documents sqrtArrowFunction as a function rather than a variable.

    Parameters

    • x: number

      the number do calculate the root of.

    Returns number

    the square root if x is non-negative or NaN if x is negative.

concat

  • concat<T>(array1: T[], array2: T[]): T[]
  • A simple generic function that concatenates two arrays.

    Use @typeParam <param name> to document generic type parameters, e.g.

    @typeParam T the element type of the arrays
    

    Type parameters

    • T

      the element type of the arrays

    Parameters

    • array1: T[]
    • array2: T[]

    Returns T[]

makeHttpCallA

  • A function that takes in an options object that is defined as a separate interface and makes an HTTP call.

    Make sure to export the options type when using this pattern. Otherwise, TypeDoc will not document the options.

    Parameters

    Returns Promise<Response>

makeHttpCallB

  • makeHttpCallB(options: { url: string; method: string; headers: Record<string, string>; body: string | Blob | FormData; mode: "cors" | "no-cors" | "same-origin" }): Promise<Response>
  • A function that takes in an options object and makes an HTTP call.

    The options type is written directly in the function definition.

    Parameters

    • options: { url: string; method: string; headers: Record<string, string>; body: string | Blob | FormData; mode: "cors" | "no-cors" | "same-origin" }
      • url: string
      • method: string

        e.g. GET, POST, PUT, DELETE

      • headers: Record<string, string>

        e.g. { 'Authorization': 'Bearer <access token>' }

      • body: string | Blob | FormData
      • mode: "cors" | "no-cors" | "same-origin"

    Returns Promise<Response>

overloadedFunction

  • overloadedFunction(a: number, b: number): string
  • overloadedFunction(a: string, b: string): string
  • Stringifies and concatenates two numbers into a single string.

    The documentation site allows you to toggle between the different overloads of a function. The implementation signature of the overloaded function is not included in the documentation.

    Parameters

    • a: number
    • b: number

    Returns string

  • Concatenates two strings.

    The documentation site allows you to toggle between the different overloads of a function. The implementation signature of the overloaded function is not included in the documentation.

    Parameters

    • a: string
    • b: string

    Returns string

anInternalFunction

  • anInternalFunction(): void
  • internal

    Use @internal to indicate that something is for internal use. If the --excludeInternal option is passed, TypeDoc will not document the given code.

    Returns void

CardA

  • CardA(__namedParameters: PropsWithChildren<CardAProps>): ReactElement
  • Renders a card around some content.

    <CardA variant="secondary">
    <h5>My Title</h5>
    <p>My content</p>
    </CardA>

    The props type is defined as a separate interface which must be exported!

    export interface CardAProps {
    // ...
    }

    export function CardA({
    children,
    variant = "primary",
    }: PropsWithChildren<CardAProps>): ReactElement {
    // ...
    }

    This is our recommended way to define React components as it makes your code more readable. The minor drawback is you must click the CardAProps link to see the component's props.

    Parameters

    Returns ReactElement

CardB

  • CardB(__namedParameters: PropsWithChildren<{ variant: "primary" | "secondary" | "success" | "danger" | "light" | "dark" }>): ReactElement
  • Renders a card around some content.

    <CardB variant="secondary">
    <h5>My Title</h5>
    <p>My content</p>
    </CardB>

    The props type is written directly in the function definition:

    export function CardB({
    children,
    variant = "primary",
    }: PropsWithChildren<{
    variant: "primary" | "secondary" | "success" | "danger" | "light" | "dark";
    }>): ReactElement {
    // ...
    }

    This can make the TypeDoc documentation a bit cleaner for very simple components, but it makes your code less readable.

    Parameters

    • __namedParameters: PropsWithChildren<{ variant: "primary" | "secondary" | "success" | "danger" | "light" | "dark" }>

    Returns ReactElement

EasyFormDialog

  • An example of a complex React component.

    A wrapper around ActionDialog that removes a lot of the boilerplate needed for dialogs that contain a form.

    interface ExampleProps {
    onSuccess(responseData: number): Promise<void>
    onClose(): void
    }

    export function Example({
    onSuccess,
    onClose,
    }: ExampleProps): ReactElement {
    const { onChildValidChange, allFieldsValid } = useFieldValidity()
    const [showValidation, setShowValidation] = useState(false)
    const vProps = { showValidation, onValidChange: onChildValidChange }

    const [myNumber, setMyNumber] = useState('')

    async function submit() {
    await api.product.performOperation()

    return {
    responseData: parseInt(myNumber),
    }
    }

    return (
    <EasyFormDialog
    title="Enter a Number"
    submitButtonText="Submit"
    formIsValid={allFieldsValid}
    showValidation={showValidation}
    onShowValidationChange={setShowValidation}
    onSubmit={submit}
    onSuccess={onSuccess}
    onClose={onClose}
    >
    <FormGroup label="My number">
    {(id) => (
    <ValidatedInput
    id={id}
    name="myNumber"
    validators={[Validators.required(), Validators.integer()]}
    value={myNumber}
    onChange={setMyNumber}
    {...vProps}
    />
    )}
    </FormGroup>
    </EasyFormDialog>
    )
    }

    Parameters

    Returns ReactElement

markdownShowcase

  • markdownShowcase(): void

syntaxHighlightingShowcase

  • syntaxHighlightingShowcase(): void
  • TypeDoc supports code blocks in Markdown and uses Shiki to provide syntax highlighting.

    If no language is specified, the code block is assumed to be TypeScript:

    // A fabulous variable
    const x: number | string = 12

    You can specify the language at the start of your code block like this:

    ```rust
    

    Use the tsx language to get JSX support:

    function BasicComponent(): ReactElement {
    return <div>Test</div>
    }

    You might want to write code in the language your backend uses. Here's some Python:

    for i in range(30):
    print(i + 1)

    And some CSS:

    .card {
    background-color: white;
    padding: 1rem;
    border: 1px solid lightgray;
    }

    If you don't want syntax highlighting, use the text language:

    package.json
    src/
        index.ts
        __tests__/
            index.test.ts
    

    View the full list of supported languages. You can also get this list by running typedoc --help.

    Returns void

Type aliases

SimpleTypeAlias

SimpleTypeAlias: string | number | boolean

A simple type alias defined using the type keyword.

ComplexGenericTypeAlias

ComplexGenericTypeAlias<T>: T | T[] | Promise<T> | Promise<T[]> | Record<string, Promise<T>>

A complex generic type.

Type parameters

  • T

Variables

PI

PI: 3.14159265359 = 3.14159265359

A simple numeric constant.

STRING_CONSTANT

STRING_CONSTANT: "FOOBAR" = "FOOBAR"

A simple string constant.

ObjectConstant

ObjectConstant: { library: "typedoc"; version: "1.2.3"; githubStars: 1000000 } = ...

An plain JavaScript object using as const.

Type declaration

  • library: "typedoc"
  • version: "1.2.3"
  • githubStars: 1000000

E

E: number = 2.718281828459045235

An exported variable defined with let.

This pattern should generally be avoided because the variable can be reassigned.

Generated using TypeDoc