@reach/utils
Advanced tools
Comparing version 0.15.0 to 0.15.2
import type * as React from "react"; | ||
declare type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2; | ||
declare type MergeProps<E, P = {}> = P & Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, P>; | ||
/** | ||
@@ -13,2 +12,5 @@ * Infers `OwnProps` if E is a ForwardRefComponent | ||
declare type NarrowIntrinsic<E> = E extends keyof JSX.IntrinsicElements ? E : never; | ||
declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & { | ||
as?: E; | ||
}>>; | ||
/** | ||
@@ -18,40 +20,18 @@ * Extends original type to ensure built in React types play nice with | ||
*/ | ||
interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}> extends React.ForwardRefExoticComponent<MergeProps<IntrinsicElementString, OwnProps & { | ||
as?: IntrinsicElementString; | ||
}>> { | ||
<As extends keyof JSX.IntrinsicElements = NarrowIntrinsic<IntrinsicElementString>>(props: MergeProps<As, OwnProps & { | ||
interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> { | ||
<As extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any> = NarrowIntrinsic<IntrinsicElementString>>(props: As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & { | ||
as: As; | ||
}>): React.ReactElement | null; | ||
/** | ||
* When passing an `as` prop as a component, use this overload. Merges | ||
* original own props (without DOM props) and the inferred props from `as` | ||
* element with the own props taking precendence. | ||
* | ||
* We don't use `React.ComponentType` here as we get type errors when | ||
* consumers try to do inline `as` components. | ||
*/ | ||
<As extends React.ElementType>(props: MergeProps<As, OwnProps & { | ||
}> : As extends React.JSXElementConstructor<infer P> ? Merge<P, OwnProps & { | ||
as: As; | ||
}>): React.ReactElement | null; | ||
}> : never): React.ReactElement | null; | ||
} | ||
interface MemoComponent<IntrinsicElementString, OwnProps = {}> extends React.MemoExoticComponent<ForwardRefComponent<MergeProps<IntrinsicElementString, OwnProps & { | ||
as?: IntrinsicElementString; | ||
}>>> { | ||
<As extends keyof JSX.IntrinsicElements = NarrowIntrinsic<IntrinsicElementString>>(props: MergeProps<As, OwnProps & { | ||
as?: As; | ||
}>): React.ReactElement | null; | ||
/** | ||
* When passing an `as` prop as a component, use this overload. Merges | ||
* original own props (without DOM props) and the inferred props from `as` | ||
* element with the own props taking precendence. | ||
* | ||
* We don't use `React.ComponentType` here as we get type errors when | ||
* consumers try to do inline `as` components. | ||
*/ | ||
<As extends React.ElementType>(props: MergeProps<As, OwnProps & { | ||
as?: As; | ||
}>): React.ReactElement | null; | ||
interface MemoComponent<IntrinsicElementString, OwnProps = {}> extends React.MemoExoticComponent<ForwardRefComponent<IntrinsicElementString, OwnProps>> { | ||
<As extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any> = NarrowIntrinsic<IntrinsicElementString>>(props: As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & { | ||
as: As; | ||
}> : As extends React.JSXElementConstructor<infer P> ? Merge<P, OwnProps & { | ||
as: As; | ||
}> : never): React.ReactElement | null; | ||
} | ||
export type { ForwardRefComponent, MemoComponent, OwnProps, IntrinsicElement, Merge, }; | ||
export type { ForwardRefComponent, IntrinsicElement, MemoComponent, Merge, OwnProps, }; | ||
declare const _default: {}; | ||
export default _default; |
{ | ||
"name": "@reach/utils", | ||
"version": "0.15.0", | ||
"version": "0.15.2", | ||
"description": "Internal, shared utilities for Reach UI.", | ||
@@ -14,3 +14,3 @@ "author": "React Training <hello@reacttraining.com>", | ||
"tiny-warning": "^1.0.3", | ||
"tslib": "^2.1.0" | ||
"tslib": "^2.3.0" | ||
}, | ||
@@ -95,3 +95,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "1449650359c119c1afe25973aa7584e09e2c88bc" | ||
"gitHead": "353f409a296a648c4fe2c2d06b14a39b7b6dc3e1" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
115977
2806
Updatedtslib@^2.3.0