kit
    Preparing search index...

    Variable invariant

    invariant: (
        condition: any,
        message?: string | (() => string),
        lib?: string,
        prefix?: string,
    ) => asserts condition = ...

    FIXME: invariant calls do not get tree shaked in minified output of projects using it. Let's not use it internally and not export it from @knitkode/utils until we find a tree-shakeable way of doing this. For now just wrapping the logging code into if (process.env["NODE_ENV"] === "development") {} works better despite it is more verbose.

    Type Declaration

      • (
            condition: any,
            message?: string | (() => string),
            lib?: string,
            prefix?: string,
        ): asserts condition
      • Parameters

        • condition: any

          The condition that, if falsy, will throw the error during development

        • Optionalmessage: string | (() => string)

          A string or a function that returns a string, "Invariant failed" by default

        • Optionallib: string

          The library name to show in the error message prefix. When prefix is also specified it outputs [lib:prefix]: the message, otherwise just [lib]: the message

        • Optionalprefix: string

          The prefix (e.g. the function name) to show in the error message prefix. When lib is also specified it outputs [lib:prefix]: the message, otherwise just [prefix]: the message

        Returns asserts condition