Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 5ab5736

Browse files
committed
feat(types): Added more optional types
1 parent 2069b2d commit 5ab5736

File tree

7 files changed

+2287
-12
lines changed

7 files changed

+2287
-12
lines changed

Diff for: index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ function getTypeFromPropType(node: any): string {
104104
return '(...args: any[]) => any';
105105
case 'React.PropTypes.object':
106106
return 'Object';
107+
case 'React.PropTypes.node':
108+
return 'React.ReactNode';
109+
case 'React.PropTypes.element':
110+
return 'React.ReactElement<any>';
107111
}
108112
}
109113
}
File renamed without changes.

Diff for: tests/simple-component.d.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ declare module 'simple-component' {
22
import * as React from 'react';
33

44
interface Props {
5-
number?: number;
6-
string?: string;
7-
array?: any[];
8-
bool?: boolean;
9-
func?: (...args: any[]) => any;
10-
object?: Object;
5+
optionalArray?: any[];
6+
optionalBool?: boolean;
7+
optionalFunc?: (...args: any[]) => any;
8+
optionalNumber?: number;
9+
optionalObject?: Object;
10+
optionalString?: string;
11+
optionalNode?: React.ReactNode;
12+
optionalElement?: React.ReactElement<any>;
1113
}
1214

1315
export default class SimpleComponent extends React.Component<Props, any> {

Diff for: tests/simple-component.jsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import * as React from 'react';
33
export default class SimpleComponent extends React.Component {
44

55
static propTypes = {
6-
number: React.PropTypes.number,
7-
string: React.PropTypes.string,
8-
array: React.PropTypes.array,
9-
bool: React.PropTypes.bool,
10-
func: React.PropTypes.func,
11-
object: React.PropTypes.object
6+
optionalArray: React.PropTypes.array,
7+
optionalBool: React.PropTypes.bool,
8+
optionalFunc: React.PropTypes.func,
9+
optionalNumber: React.PropTypes.number,
10+
optionalObject: React.PropTypes.object,
11+
optionalString: React.PropTypes.string,
12+
optionalNode: React.PropTypes.node,
13+
optionalElement: React.PropTypes.element,
1214
};
1315

1416
render() {

Diff for: tsd.json

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"installed": {
88
"node/node.d.ts": {
99
"commit": "4910a7c52a1cf335877ea3b0917eb65117a66637"
10+
},
11+
"react/react.d.ts": {
12+
"commit": "715df764419937a75a25dcd76bfc954157bc7b96"
1013
}
1114
}
1215
}

0 commit comments

Comments
 (0)