DisBot
    Preparing search index...
    • Generates more strict variant of an enum which, unlike regular enum, throws on non-existing property access. This can be useful in following situations:

      • we have an API, that accepts both undefined and SomeEnumType as an input
      • enum values are generated dynamically from DMMF.

      In that case, if using normal enums and no compile-time typechecking, using non-existing property will result in undefined value being used, which will be accepted. Using strict enum in this case will help to have a runtime exception, telling you that you are probably doing something wrong.

      Note: if you need to check for existence of a value in the enum you can still use either in operator or hasOwnProperty function.

      Type Parameters

      • T extends Record<PropertyKey, string | number>

      Parameters

      • definition: T

      Returns T