Skip to content

Commit a4db155

Browse files
authored
Add def file for react
This covers React, ReactDOM and PropTypes. However it doesn't cover full API for React since this PR is implemented based on the assumption that the user is writing JSX.
1 parent 21fd14f commit a4db155

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

defs/react.json

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"!name": "react",
3+
"!define": {
4+
"Component": {
5+
"!type": "fn()",
6+
"!url": "https://facebook.github.io/react/docs/react-api.html",
7+
"defaultProps": {
8+
"!type": "object",
9+
"!doc": "defaultProps can be defined as a property on the component class itself, to set the default props for the class.",
10+
"!url": "https://facebook.github.io/react/docs/react-component.html#defaultprops"
11+
},
12+
"displayName": {
13+
"!type": "string",
14+
"!doc": "The displayName string is used in debugging messages.",
15+
"!url": "https://facebook.github.io/react/docs/react-component.html#displayname"
16+
},
17+
"propTypes": {
18+
"!type": "PropTypes",
19+
"!doc": "To run typechecking on the props for a component, you can assign the special propTypes property.",
20+
"!url": "https://facebook.github.io/react/docs/typechecking-with-proptypes.html"
21+
},
22+
"prototype": {
23+
"props": "object",
24+
"state": "object",
25+
"setState": {
26+
"!type": "fn(updater: object, callback?: fn())",
27+
"!doc": "setState() enqueues changes to the component state and tells React that this component and its children need to be re-rendered with the updated state.",
28+
"!url": "https://facebook.github.io/react/docs/react-component.html#setstate"
29+
},
30+
"forceUpdate": {
31+
"!type": "fn(callback: fn())",
32+
"!doc": "By default, when your component's state or props change, your component will re-render. If your render() method depends on some other data, you can tell React that the component needs re-rendering by calling forceUpdate().",
33+
"!url": "https://facebook.github.io/react/docs/react-component.html#forceupdate"
34+
}
35+
}
36+
},
37+
"PropTypes": {
38+
"!doc": "Runtime type checking for React props and similar objects.",
39+
"!url": "https://github.com/facebook/prop-types/",
40+
"array": {
41+
"!type": "PropType",
42+
"!doc": "You can declare that a prop is a specific JS primitive."
43+
},
44+
"bool": {
45+
"!type": "PropType",
46+
"!doc": "You can declare that a prop is a specific JS primitive."
47+
},
48+
"func": {
49+
"!type": "PropType",
50+
"!doc": "You can declare that a prop is a specific JS primitive."
51+
},
52+
"number": {
53+
"!type": "PropType",
54+
"!doc": "You can declare that a prop is a specific JS primitive."
55+
},
56+
"object": {
57+
"!type": "PropType",
58+
"!doc": "You can declare that a prop is a specific JS primitive."
59+
},
60+
"string": {
61+
"!type": "PropType",
62+
"!doc": "You can declare that a prop is a specific JS primitive."
63+
},
64+
"symbol": {
65+
"!type": "PropType",
66+
"!doc": "You can declare that a prop is a specific JS primitive."
67+
},
68+
"node": {
69+
"!type": "PropType",
70+
"!doc": "Anything that can be rendered: numbers, strings, elements or an array (or fragment) containing these types."
71+
},
72+
"element": {
73+
"!type": "PropType",
74+
"!doc": "A React element."
75+
},
76+
"instanceOf": {
77+
"!type": "fn(class: fn()) -> PropType",
78+
"!doc": "You can also declare that a prop is an instance of a class. This uses JS's instanceof operator."
79+
},
80+
"oneOf": {
81+
"!type": "fn([?]) -> PropType",
82+
"!doc": "You can ensure that your prop is limited to specific values by treating it as an enum."
83+
},
84+
"oneOfType": {
85+
"!type": "fn([PropType]) -> PropType",
86+
"!doc": "An object that could be one of many types"
87+
},
88+
"arrayOf": {
89+
"!type": "fn(propType: PropType) -> PropType",
90+
"!doc": "An array of a certain type"
91+
},
92+
"objectOf": {
93+
"!type": "fn(propType: PropType) -> PropType",
94+
"!doc": "An object with property values of a certain type"
95+
},
96+
"shape": {
97+
"!type": "fn(propTypes: PropTypes) -> PropType",
98+
"!doc": "An object taking on a particular shape"
99+
},
100+
"any": {
101+
"!type": "PropType",
102+
"!doc": "A value of any data type"
103+
}
104+
},
105+
"PropType": {
106+
"isRequired": {
107+
"!doc": "You can chain any of the above with `isRequired` to make sure a warning is shown if the prop isn't provided"
108+
}
109+
}
110+
},
111+
"PropTypes": "PropTypes",
112+
"React": {
113+
"Component": "Component",
114+
"PureComponent": "Component"
115+
},
116+
"ReactDOM": {
117+
"render": {
118+
"!type": "fn(element: PropTypes.element, container: Element, callback?: fn()) -> !0",
119+
"!doc": "Render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components).",
120+
"!url": "https://facebook.github.io/react/docs/react-dom.html#render"
121+
},
122+
"unmountComponentAtNode": {
123+
"!type": "fn(container: Element) -> bool",
124+
"!doc": "Remove a mounted React component from the DOM and clean up its event handlers and state.",
125+
"!url": "https://facebook.github.io/react/docs/react-dom.html#unmountcomponentatnode"
126+
},
127+
"findDOMNode": {
128+
"!type": "fn(component: PropTypes.element) -> Element",
129+
"!doc": "If this component has been mounted into the DOM, this returns the corresponding native browser DOM element.",
130+
"!url": "https://facebook.github.io/react/docs/react-dom.html#finddomnode"
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)