Skip to content

Commit f293409

Browse files
Tranceversouhe
authored andcommitted
fix: use own opy of types for hoist-non-react-statics (#69)
1 parent 22d67bc commit f293409

File tree

5 files changed

+100
-36
lines changed

5 files changed

+100
-36
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"react": "^16.3.0"
5555
},
5656
"dependencies": {
57-
"@types/hoist-non-react-statics": "^3.3.1",
5857
"deepmerge": "^3.2.0",
5958
"hoist-non-react-statics": "^3.3.0"
6059
},

typings/__tests__/index.test.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from "react";
2-
import { createTheming } from "../..";
1+
import * as React from 'react';
2+
import { createTheming } from '../..';
33

44
type Theme = {
55
primaryColor: string;
@@ -11,24 +11,22 @@ type Theme = {
1111

1212
const themes: { [key: string]: Theme } = {
1313
default: {
14-
primaryColor: "#FFA72A",
15-
accentColor: "#458622",
16-
backgroundColor: "#FFC777",
17-
textColor: "#504f4d",
18-
secondaryColor: "#7F5315"
14+
primaryColor: '#FFA72A',
15+
accentColor: '#458622',
16+
backgroundColor: '#FFC777',
17+
textColor: '#504f4d',
18+
secondaryColor: '#7F5315',
1919
},
2020
dark: {
21-
primaryColor: "#FFA72A",
22-
accentColor: "#458622",
23-
backgroundColor: "#504f4d",
24-
textColor: "#FFC777",
25-
secondaryColor: "#252525"
26-
}
21+
primaryColor: '#FFA72A',
22+
accentColor: '#458622',
23+
backgroundColor: '#504f4d',
24+
textColor: '#FFC777',
25+
secondaryColor: '#252525',
26+
},
2727
};
2828

29-
const { ThemeProvider, withTheme } = createTheming<Theme>(
30-
themes.default
31-
);
29+
const { ThemeProvider, withTheme } = createTheming<Theme>(themes.default);
3230

3331
type TitleComponentProps = {
3432
title: string;
@@ -39,7 +37,7 @@ const TitleComponent = ({ title, theme }: TitleComponentProps) => (
3937
<div
4038
style={{
4139
backgroundColor: theme.backgroundColor,
42-
color: theme.primaryColor
40+
color: theme.primaryColor,
4341
}}
4442
>
4543
{title}
@@ -50,7 +48,10 @@ const ThemedTitle = withTheme(TitleComponent);
5048

5149
const App = () => (
5250
<ThemeProvider theme={themes.default}>
53-
<ThemedTitle title="React Theme Provider" theme={{ primaryColor: 'pink' }} />
51+
<ThemedTitle
52+
title="React Theme Provider"
53+
theme={{ primaryColor: 'pink' }}
54+
/>
5455
<ThemedTitle title="Second title" />
5556
</ThemeProvider>
5657
);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Type definitions for hoist-non-react-statics 3.3
2+
// Project: https://github.com/mridgway/hoist-non-react-statics#readme
3+
// Definitions by: JounQin <https://github.com/JounQin>, James Reggio <https://github.com/jamesreggio>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
// TypeScript Version: 2.8
6+
7+
import * as React from 'react';
8+
9+
interface REACT_STATICS {
10+
childContextTypes: true;
11+
contextType: true;
12+
contextTypes: true;
13+
defaultProps: true;
14+
displayName: true;
15+
getDefaultProps: true;
16+
getDerivedStateFromError: true;
17+
getDerivedStateFromProps: true;
18+
mixins: true;
19+
propTypes: true;
20+
type: true;
21+
}
22+
23+
interface KNOWN_STATICS {
24+
name: true;
25+
length: true;
26+
prototype: true;
27+
caller: true;
28+
callee: true;
29+
arguments: true;
30+
arity: true;
31+
}
32+
33+
interface MEMO_STATICS {
34+
$$typeof: true;
35+
compare: true;
36+
defaultProps: true;
37+
displayName: true;
38+
propTypes: true;
39+
type: true;
40+
}
41+
42+
interface FORWARD_REF_STATICS {
43+
$$typeof: true;
44+
render: true;
45+
defaultProps: true;
46+
displayName: true;
47+
propTypes: true;
48+
}
49+
50+
declare namespace hoistNonReactStatics {
51+
type NonReactStatics<
52+
S extends React.ComponentType<any>,
53+
C extends {
54+
[key: string]: true;
55+
} = {}
56+
> = {
57+
[key in Exclude<
58+
keyof S,
59+
S extends React.MemoExoticComponent<any>
60+
? keyof MEMO_STATICS | keyof C
61+
: S extends React.ForwardRefExoticComponent<any>
62+
? keyof FORWARD_REF_STATICS | keyof C
63+
: keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C
64+
>]: S[key]
65+
};
66+
}
67+
68+
declare function hoistNonReactStatics<
69+
T extends React.ComponentType<any>,
70+
S extends React.ComponentType<any>,
71+
C extends {
72+
[key: string]: true;
73+
} = {}
74+
>(
75+
TargetComponent: T,
76+
SourceComponent: S,
77+
customStatic?: C
78+
): T & hoistNonReactStatics.NonReactStatics<S, C>;
79+
80+
export = hoistNonReactStatics;

typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// TypeScript version 3.0.3
33

44
import * as React from 'react';
5-
import hoistNonReactStatics = require('hoist-non-react-statics');
5+
import hoistNonReactStatics = require('./hoist-non-react-statics');
66

77
type $Without<T, K> = Pick<T, Exclude<keyof T, K>>;
88
type $DeepPartial<T> = { [P in keyof T]?: $DeepPartial<T[P]> };

yarn.lock

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -904,14 +904,6 @@
904904
dependencies:
905905
"@babel/types" "^7.3.0"
906906

907-
"@types/hoist-non-react-statics@^3.3.1":
908-
version "3.3.1"
909-
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
910-
integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==
911-
dependencies:
912-
"@types/react" "*"
913-
hoist-non-react-statics "^3.3.0"
914-
915907
"@types/istanbul-lib-coverage@^1.1.0":
916908
version "1.1.0"
917909
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz#2cc2ca41051498382b43157c8227fea60363f94a"
@@ -927,14 +919,6 @@
927919
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.8.tgz#8ae4e0ea205fe95c3901a5a1df7f66495e3a56ce"
928920
integrity sha512-3AQoUxQcQtLHsK25wtTWIoIpgYjH3vSDroZOUr7PpCHw/jLY1RB9z9E8dBT/OSmwStVgkRNvdh+ZHNiomRieaw==
929921

930-
"@types/react@*":
931-
version "16.8.20"
932-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.20.tgz#4f633ecbd0a4d56d0ccc50fff6f9321bbcd7d583"
933-
integrity sha512-ZLmI+ubSJpfUIlQuULDDrdyuFQORBuGOvNnMue8HeA0GVrAJbWtZQhcBvnBPNRBI/GrfSfrKPFhthzC2SLEtLQ==
934-
dependencies:
935-
"@types/prop-types" "*"
936-
csstype "^2.2.0"
937-
938922
"@types/react@^16.8.8":
939923
version "16.8.8"
940924
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.8.tgz#4b60a469fd2469f7aa6eaa0f8cfbc51f6d76e662"

0 commit comments

Comments
 (0)