11// Copied directly from:
22// https://github.com/mridgway/hoist-non-react-statics/blob/main/src/index.js
3- // https://unpkg.com/browse/@types /[email protected] .1 /index.d.ts 3+ // https://unpkg.com/browse/@types /[email protected] .6 /index.d.ts 44
55/**
66 * Copyright 2015, Yahoo! Inc.
77 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
88 */
9- import type {
10- ComponentType ,
11- ForwardRefExoticComponent ,
12- MemoExoticComponent ,
13- } from 'react'
9+ import type { ForwardRefExoticComponent , MemoExoticComponent } from 'react'
1410import { ForwardRef , Memo , isMemo } from '../utils/react-is'
1511
1612const REACT_STATICS = {
@@ -70,19 +66,19 @@ function getStatics(component: any) {
7066}
7167
7268export type NonReactStatics <
73- S extends ComponentType < any > ,
69+ Source ,
7470 C extends {
7571 [ key : string ] : true
7672 } = { } ,
7773> = {
7874 [ key in Exclude <
79- keyof S ,
80- S extends MemoExoticComponent < any >
75+ keyof Source ,
76+ Source extends MemoExoticComponent < any >
8177 ? keyof typeof MEMO_STATICS | keyof C
82- : S extends ForwardRefExoticComponent < any >
78+ : Source extends ForwardRefExoticComponent < any >
8379 ? keyof typeof FORWARD_REF_STATICS | keyof C
8480 : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C
85- > ] : S [ key ]
81+ > ] : Source [ key ]
8682}
8783
8884const defineProperty = Object . defineProperty
@@ -93,12 +89,15 @@ const getPrototypeOf = Object.getPrototypeOf
9389const objectPrototype = Object . prototype
9490
9591export default function hoistNonReactStatics <
96- T extends ComponentType < any > ,
97- S extends ComponentType < any > ,
98- C extends {
92+ Target ,
93+ Source ,
94+ CustomStatic extends {
9995 [ key : string ] : true
10096 } = { } ,
101- > ( targetComponent : T , sourceComponent : S ) : T & NonReactStatics < S , C > {
97+ > (
98+ targetComponent : Target ,
99+ sourceComponent : Source ,
100+ ) : Target & NonReactStatics < Source , CustomStatic > {
102101 if ( typeof sourceComponent !== 'string' ) {
103102 // don't hoist over string (html) components
104103
0 commit comments