object-shape-tester - v6.9.2
    Preparing search index...

    Function typedStringShape

    • Creates a shape that requires a string and gives it a specific type. This does not apply any extra type safety beyond string checking.

      Type Parameters

      • const T extends string

      Parameters

      • defaultValue: string = ''

      Returns Shape<TUnsafe<T>>

      import {typedString, checkValidShape} from 'object-shape-tester';

      const myShape = typedString<`${string}-${string}`>();

      checkValidShape('1-2', myShape); // `true`
      checkValidShape('1', myShape); // `true`
      checkValidShape(1, myShape); // `false`