UNPKG

@spark-web/utils

Version:

--- title: Utilities isExperimentalPackage: true ---

33 lines (29 loc) 1.19 kB
import { forwardRef } from 'react'; export { a as isBoolean, i as isFunction, b as isNumber, c as isString } from '../../dist/type-check-d8c35507.esm.js'; /** * This is a hack for sure. The thing is, getting a component to intelligently * infer props based on a component or JSX string passed into an `as` prop is * kind of a huge pain. Getting it to work and satisfy the constraints of * `forwardRef` seems dang near impossible. To avoid needing to do this awkward * type song-and-dance every time we want to forward a ref into a component * that accepts an `as` prop, we abstract all of that mess to this function for * the time time being. */ var forwardRefWithAs = function forwardRefWithAs(render) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return /*#__PURE__*/forwardRef(render); }; /** * An alternative to `Object.keys()` that avoids type widening. * * @param {object} value Object containing keys to extract * * @example * Object.keys({ foo: 1, bar: 2 }) // string[] * typedKeys({ foo: 1, bar: 2 }) // ("foo" | "bar")[] */ function typedKeys(value) { return Object.keys(value); } export { forwardRefWithAs, typedKeys };