Commit Graph

67 Commits

Author SHA1 Message Date
Alexander Chudesnov
6922165cbb Allow children in stateless components’ props
This allows passing children to `StatelessComponent<P>` exactly like base components without the need to use React.Props<T> or extending the P interface with an explicit 'children' property:

# Before
````typescript
    type FooProps = {
      bar: number;
    }
    const Foo: React.SFC<FooProps> = props => (
      <div>
        {props.children} = {props.bar} // error TS2459: Type 'FooProps' has no property 'children' and no string index signature.
      </div>
    );
````

# After
````typescript
    type FooProps = {
      bar: number;
    }
    const Foo: React.SFC<FooProps> = props => (
      <div>
        {props.children} = {props.bar}
      </div>
    );

    <Foo bar="42">6×9</Foo> // <div>6×9 = 42</div>
````
2016-11-09 21:58:54 +03:00
Linken Dinh
7f9ddef9b8 [types-2.0] react - better strict mode compatibility (#11935)
* strict mode compatible

* include 11931

* vsiao - code review

* vsiao - code review - revert complex cloneelement case

* validator to accept null

* remove double tests

* test use Error | null

* code reviews

* code reviews
2016-11-08 23:53:49 +09:00
David Zearing
732b0378d8 Updating capture events + test. (#12327)
* Updating capture events + test.

* Updating Capture methods to be inlined.

* Removing mouse enter/leave captures.
2016-11-08 22:25:07 +09:00
Rob Yoder
73b855f753 Add fillRule to SVGAttributes 2016-10-27 22:40:25 -06:00
Melvin Groenhoff
4ecf3ce8aa Allow passing extra arguments to proptype validators to silence deprecation warnings. 2016-10-10 16:43:42 +02:00
beckend
5fe46ff8c8 [TS 2] React Component/PureComponent constructor super accept rest params (#11612) 2016-10-03 14:47:36 -07:00
Paul van Brenk
389c99a47f fix react 2016-08-19 13:40:17 -07:00
Paul van Brenk
5c77befaaa fix break 2016-08-19 10:53:44 -07:00
Paul van Brenk
2a10e28ad4 New typings migrated to 2.0 2016-08-18 16:39:16 -07:00
Ryan Cavanaugh
c33a46c3d5 Merge commit 'upstream/master~200' into merge_7_25 2016-07-26 18:25:24 -07:00
Ryan Cavanaugh
e94e9a8630 Merge commit 'upstream/master~450' into merge_7_25 2016-07-26 13:40:56 -07:00
Stevi Deter
c34251f96b Types 2.0 ReactDom.render (#10206)
* For ReactDOM.render, make element parameter nullable to match React API and match Typescript 2.0 definition for Document.getElementById

* one more test
2016-07-23 23:38:28 -07:00
Ryan Cavanaugh
9d7d5a209a Getting types-2.0 passing CI 2016-07-14 18:13:43 -07:00
phiresky
084926e23a
react: Add target type to events
this allows getting the actual html element type from events.

Example:

```ts
render() {
    return <input onChange={e => console.log(e.target.value)}/>
}
```

Previously you would have to cast the target manually:
```ts
render() {
    return <input onChange={e => console.log((e.target as
    HTMLInputElement).value)}/>
}
```
2016-07-03 20:23:20 +02:00
Ryan Cavanaugh
925dbd5230 Merge pull request #8753 from jwbay/react-transition-group-props
TransitionGroup spreads HTMLAttribute props onto its component
2016-06-30 17:13:52 -07:00
Thanabodee Charoenpiriyakij
9a062b06b6 react: fix duplicate statelessElement in react-tests.ts 2016-06-30 17:31:54 +07:00
Linda_pp
50b9b6c6d5 react-addons-perf: Update APIs to version 15.1.0 (#9662)
* react-addons-perf: Update APIs to version 15.1.0

https://facebook.github.io/react/docs/perf.html

* Add deprecation comment to printDOM()

* Add more exported APIs

d101f68bce/src/renderers/shared/ReactPerf.js (L432)
2016-06-19 12:19:33 +09:00
Ryan Cavanaugh
185c8f30b6 Fix more reference paths 2016-05-11 16:31:46 -07:00
Ryan Cavanaugh
e105eabd48 Remove invalid references 2016-05-10 16:27:59 -07:00
Ryan Cavanaugh
e808e8e062 Remove unneeded references 2016-05-10 12:22:25 -07:00
Nicholas Lydon
08ed4e9f18 React TestUtils SyntheticEventData extends browser Event (#9000)
* SyntheticEventData extends browser Event

From https://facebook.github.io/react/docs/events.html

Your event handlers will be passed instances of SyntheticEvent, a
cross-browser wrapper around the browser's native event. It has the same
interface as the browser's native event, including stopPropagation() and
preventDefault(), except the events work identically across all
browsers.

* make react synthetic event properties optional
2016-04-27 12:56:38 +09:00
Sean Kelley
b9642fb8ac Allow specifying void for component state type parameter. (#8673)
* Allow specifying `void` for component state type parameter.

Per comments on https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8543,
the type parameter for component state was changed to `{}` from `any` for
increased type safety, but prevents specifying (non-functional) stateless
components without having empty state parameters, which seems messy. This
changes the type to `{} | void` to allow this while staying stricter than
`any`.

* Make react tests a bit more strict.

* Rename State -> ComponentState to make it a bit more explicit.
2016-04-13 00:40:40 +09:00
Justin Bay
7c5dbff213 TransitionGroup spreads HTMLAttribute props onto its component 2016-03-28 13:55:13 -04:00
Vincent Siao
1a67b639ce [react] Add ComponentElement<P, T> for instance type inference 2016-03-14 02:05:24 -07:00
Vincent Siao
5e85e146c6 [react] ReactTestUtils custom typeguards 2016-03-14 01:46:14 -07:00
Vincent Siao
1917a4122a [react] Add T param to React.DOM* types 2016-03-14 01:46:13 -07:00
Vincent Siao
92cf86a3e2 [react] Deprecate React.Props<T>; Add React.*Attributes 2016-03-14 01:46:13 -07:00
Vincent Siao
edb41e7850 [react] better return-type inference for (scry|find)RenderedComponent(s?)WithType 2016-02-26 18:33:14 -08:00
Vincent Siao
a3d2b67d36 [react] improve React.cloneElement with F-bounded polymorphism 2016-02-26 18:33:14 -08:00
Vincent Siao
d76bfa3394 [React] Add SFC displayName and fix onlyChild type
- `StatelessComponent` is missing an optional `displayName` property
- `ReactChildren.only` always returns a `ReactElement`
- add tests for the above and `ReactTestUtils.renderIntoDocument`
2015-12-09 12:07:28 -08:00
Ryan Cavanaugh
d7465b3fbe Merge branch 'master' into reactSFC 2015-12-01 14:26:53 -08:00
Adi Dahiya
ca5bfe76d2 Fix linting errors in react typings 2015-11-18 14:37:45 -05:00
Ryan Cavanaugh
f4e53f321c Update react-tests.ts 2015-11-12 15:20:28 -08:00
James Brantly
bb72880cd3 Add custom classes support to CSSTransitionGroup 2015-11-11 08:55:17 -05:00
Vincent Siao
813f3b03db [React.14] Add checkedLink/valueLink to HTMLAttributes for LinkedStateMixin 2015-11-10 23:43:36 -08:00
Vincent Siao
84340fabfc Merge branch 'react-v14' of github.com:jbrantly/DefinitelyTyped into react-v14 2015-11-09 17:43:58 -08:00
Vincent Siao
8345d38855 [React.14] Add StatelessComponent<P> and tests
- Also add image to JSX.IntrinsicElements
- Add tests for callback and string refs
- Fix bug where Component<P, S> subclasses are required to have defaultProps
2015-11-09 17:39:55 -08:00
Phips Peter
cba13a3b25 Add shallow-compare addon
Interestingly, I do not believe that the ComponentLifecycle interface is
propagated to components that inherit from React.Component.
2015-11-05 17:56:28 -08:00
Vincent Siao
15eff541e0 [React.14] Update refs for DOM elements 2015-11-05 10:41:07 -08:00
James Brantly
619033254c Update tests for v0.14 and refactor how addons expose interfaces. 2015-11-05 07:01:14 -05:00
Tom Hasner
bf061642b0 Write typings for React.Children.toArray and React.Children.map 2015-11-02 22:59:15 -05:00
Ciuca, Alexandru
64cd3d9c56 Fixed react tests caused by incompatibility of aliased props generics 2015-09-17 20:11:06 +03:00
Daniel Rosenwasser
d333e3deb0 Add type annotation to avoid complaining about missing index signature in 'react'. 2015-08-20 16:53:36 -07:00
Daniel Rosenwasser
d2f69d40ab Add index signature to 'ComponentSpec' in 'react'. 2015-08-20 14:32:32 -07:00
Ciuca, Alexandru
1a9ee560ef react - Replaced any with {} for context
See https://github.com/Microsoft/TypeScript/issues/4126
2015-08-04 11:10:07 +03:00
vvakame
523dc9d483 fix react/react-tests.ts and react/react-addons-tests.ts compile error 2015-04-15 23:23:21 +09:00
Vincent Siao
424bb99eac Don't use DOM API interfaces for React.SVGAttributes 2015-03-14 16:15:59 -07:00
Vincent Siao
0213f7c10e Fix state initializers in react-tests.ts (Fixes #3855) 2015-03-14 15:29:15 -07:00
Phips Peter
57340eca1e Moving React 0.13 to be the default
React 0.13 is now released so it should be the default type definition.
http://facebook.github.io/react/blog/2015/03/10/react-v0.13.html
2015-03-10 19:03:37 -07:00
Vincent Siao
54e4632ca7 Revert "Change most uses of ComponentClass<P> to a type that represents the class"
This reverts commit 7bb2b48cd2.

Conflicts:
	react/react.d.ts
2015-01-22 18:51:18 -08:00