when.d.ts 918 B

1234567891011121314151617181920212223242526
  1. /**
  2. * @license
  3. * Copyright 2021 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /**
  7. * When `condition` is true, returns the result of calling `trueCase()`, else
  8. * returns the result of calling `falseCase()` if `falseCase` is defined.
  9. *
  10. * This is a convenience wrapper around a ternary expression that makes it a
  11. * little nicer to write an inline conditional without an else.
  12. *
  13. * @example
  14. *
  15. * ```ts
  16. * render() {
  17. * return html`
  18. * ${when(this.user, () => html`User: ${this.user.username}`, () => html`Sign In...`)}
  19. * `;
  20. * }
  21. * ```
  22. */
  23. export declare function when<T, F>(condition: true, trueCase: () => T, falseCase?: () => F): T;
  24. export declare function when<T, F = undefined>(condition: false, trueCase: () => T, falseCase?: () => F): F;
  25. export declare function when<T, F = undefined>(condition: unknown, trueCase: () => T, falseCase?: () => F): T | F;
  26. //# sourceMappingURL=when.d.ts.map