diff --git a/types/create-react-class/index.d.ts b/types/create-react-class/index.d.ts index 9a1b0b12b5..9b9d2b2ad5 100644 --- a/types/create-react-class/index.d.ts +++ b/types/create-react-class/index.d.ts @@ -2,7 +2,7 @@ // Project: https://facebook.github.io/react/ // Definitions by: John Gozde // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { ComponentSpec, ClassicComponentClass } from "react"; diff --git a/types/gestalt/index.d.ts b/types/gestalt/index.d.ts index d3ceb5672e..162d61dd52 100644 --- a/types/gestalt/index.d.ts +++ b/types/gestalt/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/pinterest/gestalt // Definitions by: Nicolás Serrano Arévalo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from "react"; diff --git a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx index 9767614bcc..0e1beed2e9 100644 --- a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx +++ b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx @@ -1,13 +1,14 @@ -import * as React from 'react'; +import * as React from 'react'; import * as PropTypes from 'prop-types'; import hoistNonReactStatics = require('hoist-non-react-statics'); -class A extends React.Component<{x: number, y?: number}> { +class A extends React.Component<{ x: number; y?: number | null }> { static a = 'a'; static propTypes = { - m: PropTypes.number.isRequired + x: PropTypes.number.isRequired, + y: PropTypes.number, }; getA() { @@ -19,7 +20,7 @@ class B extends React.Component { static b = 'b'; static propTypes = { - n: PropTypes.number.isRequired + n: PropTypes.number.isRequired, }; getB() { @@ -31,13 +32,13 @@ const C = hoistNonReactStatics(A, B); C.a !== C.b; -C.propTypes.m; +C.propTypes.x; C.prototype.getA(); C.propTypes.n; // $ExpectError C.prototype.getB(); // $ExpectError -; +; const D = hoistNonReactStatics(A, B, { a: true, b: true }); diff --git a/types/react-adal/index.d.ts b/types/react-adal/index.d.ts index 9f3cd9bef2..40a8d5d3bc 100644 --- a/types/react-adal/index.d.ts +++ b/types/react-adal/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/salvoravida/react-adal#readme // Definitions by: Dmitry Korolev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-addons-create-fragment/index.d.ts b/types/react-addons-create-fragment/index.d.ts index 1e46046ec4..25e4ba9b43 100644 --- a/types/react-addons-create-fragment/index.d.ts +++ b/types/react-addons-create-fragment/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-addons-css-transition-group/index.d.ts b/types/react-addons-css-transition-group/index.d.ts index 33d43b4cd1..03cdc48303 100644 --- a/types/react-addons-css-transition-group/index.d.ts +++ b/types/react-addons-css-transition-group/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import 'react-addons-transition-group'; import { ComponentClass, CSSTransitionGroupProps } from 'react'; diff --git a/types/react-addons-linked-state-mixin/index.d.ts b/types/react-addons-linked-state-mixin/index.d.ts index 6358dde535..1c590e333f 100644 --- a/types/react-addons-linked-state-mixin/index.d.ts +++ b/types/react-addons-linked-state-mixin/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { Mixin } from 'react'; diff --git a/types/react-addons-pure-render-mixin/index.d.ts b/types/react-addons-pure-render-mixin/index.d.ts index 565a108721..a154dbe594 100644 --- a/types/react-addons-pure-render-mixin/index.d.ts +++ b/types/react-addons-pure-render-mixin/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { Mixin } from 'react'; diff --git a/types/react-addons-shallow-compare/index.d.ts b/types/react-addons-shallow-compare/index.d.ts index ff4e5dbdc9..5d6942ed24 100644 --- a/types/react-addons-shallow-compare/index.d.ts +++ b/types/react-addons-shallow-compare/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { Component } from 'react'; diff --git a/types/react-addons-test-utils/index.d.ts b/types/react-addons-test-utils/index.d.ts index 9282f95f4e..0531c5e3f6 100644 --- a/types/react-addons-test-utils/index.d.ts +++ b/types/react-addons-test-utils/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { AbstractView, Component, ComponentClass, ReactElement, ReactInstance, ClassType, diff --git a/types/react-addons-transition-group/index.d.ts b/types/react-addons-transition-group/index.d.ts index 933533df28..79f76bf84e 100644 --- a/types/react-addons-transition-group/index.d.ts +++ b/types/react-addons-transition-group/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { ComponentClass, TransitionGroupProps } from 'react'; diff --git a/types/react-addons-update/index.d.ts b/types/react-addons-update/index.d.ts index 874549b7a1..5a1018d2c2 100644 --- a/types/react-addons-update/index.d.ts +++ b/types/react-addons-update/index.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-aria-modal/index.d.ts b/types/react-aria-modal/index.d.ts index 83ca6d3a34..4083d08473 100644 --- a/types/react-aria-modal/index.d.ts +++ b/types/react-aria-modal/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/davidtheclark/react-aria-modal#readme // Definitions by: forabi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import React = require('react'); diff --git a/types/react-dom-factories/index.d.ts b/types/react-dom-factories/index.d.ts index eaf04f766f..b0bcb5bfa6 100644 --- a/types/react-dom-factories/index.d.ts +++ b/types/react-dom-factories/index.d.ts @@ -2,7 +2,7 @@ // Project: https://facebook.github.io/react/ // Definitions by: John Gozde // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 export as namespace ReactDOMFactories; export = ReactDOMFactories; diff --git a/types/react-dom/index.d.ts b/types/react-dom/index.d.ts index e7a5afe59d..518c0c617c 100644 --- a/types/react-dom/index.d.ts +++ b/types/react-dom/index.d.ts @@ -6,7 +6,7 @@ // MartynasZilinskas // Josh Rutherford // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 export as namespace ReactDOM; diff --git a/types/react-dom/v15/index.d.ts b/types/react-dom/v15/index.d.ts index bd39e0a5e1..8a22fd9bc2 100644 --- a/types/react-dom/v15/index.d.ts +++ b/types/react-dom/v15/index.d.ts @@ -5,7 +5,7 @@ // Microsoft // MartynasZilinskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 export as namespace ReactDOM; diff --git a/types/react-dragtastic/index.d.ts b/types/react-dragtastic/index.d.ts index 64ce099e2f..fbfaf42cff 100644 --- a/types/react-dragtastic/index.d.ts +++ b/types/react-dragtastic/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/chrisjpatty/react-dragtastic#readme // Definitions by: Nicolás Scarcella // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { ReactNode, Component, MouseEventHandler, TouchEventHandler } from 'react'; diff --git a/types/react-flag-icon-css/index.d.ts b/types/react-flag-icon-css/index.d.ts index ad1777670a..74c3e04efe 100644 --- a/types/react-flag-icon-css/index.d.ts +++ b/types/react-flag-icon-css/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/matteocng/react-flag-icon-css#readme // Definitions by: Jon Freedman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as CSS from 'csstype'; import { PureComponent, ReactNode } from 'react'; diff --git a/types/react-highlight/index.d.ts b/types/react-highlight/index.d.ts index 2ab09ee3a9..715a25b23b 100644 --- a/types/react-highlight/index.d.ts +++ b/types/react-highlight/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/akiran/react-highlight // Definitions by: Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from "react"; diff --git a/types/react-input-autosize/index.d.ts b/types/react-input-autosize/index.d.ts index f8f6f5b06f..0a86381736 100644 --- a/types/react-input-autosize/index.d.ts +++ b/types/react-input-autosize/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/JedWatson/react-input-autosize#readme // Definitions by: Jason Unger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 2ed6eb0d98..782c4de889 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -4,6 +4,7 @@ */ import * as React from "react"; +import * as PropTypes from "prop-types"; import * as reactMixin from "react-mixin"; import { @@ -63,8 +64,9 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass }); class SomeComponent extends React.Component { - static propTypes: React.ValidationMap = { - intl: intlShape.isRequired + static propTypes: React.ValidationMap = { + intl: intlShape.isRequired, + className: PropTypes.string.isRequired }; render(): React.ReactElement<{}> { const intl = this.props.intl; diff --git a/types/react-no-ssr/index.d.ts b/types/react-no-ssr/index.d.ts index 77d52af1ff..9ca00149d0 100644 --- a/types/react-no-ssr/index.d.ts +++ b/types/react-no-ssr/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/kadirahq/react-no-ssr // Definitions by: Rafał Filipek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-plotly.js/index.d.ts b/types/react-plotly.js/index.d.ts index ac24016496..4dfc3b0ce3 100644 --- a/types/react-plotly.js/index.d.ts +++ b/types/react-plotly.js/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/plotly/react-plotly.js#readme // Definitions by: Jon Freedman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as Plotly from 'plotly.js'; import * as React from 'react'; diff --git a/types/react-portal/v3/index.d.ts b/types/react-portal/v3/index.d.ts index 7595c5e8ad..4d869009e6 100644 --- a/types/react-portal/v3/index.d.ts +++ b/types/react-portal/v3/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/tajo/react-portal#readme // Definitions by: Shun Takahashi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from "react"; diff --git a/types/react-qr-reader/index.d.ts b/types/react-qr-reader/index.d.ts index d58da0e89f..de426667c0 100644 --- a/types/react-qr-reader/index.d.ts +++ b/types/react-qr-reader/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/JodusNodus/react-qr-reader // Definitions by: David Kevork // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from "react"; diff --git a/types/react-select/test/examples/Experimental.tsx b/types/react-select/test/examples/Experimental.tsx index c0bbf3c6ad..1317abbf5a 100644 --- a/types/react-select/test/examples/Experimental.tsx +++ b/types/react-select/test/examples/Experimental.tsx @@ -89,7 +89,7 @@ const daysHeaderItemStyles = { cursor: 'default', // display: 'block', fontSize: '75%', - fontWeight: 500, + fontWeight: 500 as 500, display: 'inline-block', width: '12%', margin: '0 1%', diff --git a/types/react-select/v1/index.d.ts b/types/react-select/v1/index.d.ts index 31ff0db561..59bea6d815 100644 --- a/types/react-select/v1/index.d.ts +++ b/types/react-select/v1/index.d.ts @@ -16,7 +16,7 @@ // Endurance Idehen // Guillaume Chartier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; diff --git a/types/react-test-renderer/v15/tsconfig.json b/types/react-test-renderer/v15/tsconfig.json index 4be2e2797f..0c98103ec8 100644 --- a/types/react-test-renderer/v15/tsconfig.json +++ b/types/react-test-renderer/v15/tsconfig.json @@ -9,6 +9,9 @@ "react": [ "react/v15" ], + "react-dom": [ + "react-dom/v15" + ], "react-test-renderer": [ "react-test-renderer/v15" ] @@ -30,4 +33,4 @@ "shallow/index.d.ts", "react-test-renderer-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/react/index.d.ts b/types/react/index.d.ts index c130068ca0..2c7110237c 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -19,11 +19,12 @@ // Olivier Pascal // Martin Hochel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /// import * as CSS from 'csstype'; +import * as PropTypes from 'prop-types'; type NativeAnimationEvent = AnimationEvent; type NativeClipboardEvent = ClipboardEvent; @@ -2205,30 +2206,28 @@ declare namespace React { // React.PropTypes // ---------------------------------------------------------------------- - type Validator = { bivarianceHack(object: T, key: string, componentName: string, ...rest: any[]): Error | null }["bivarianceHack"]; + type Validator = PropTypes.Validator; - interface Requireable extends Validator { - isRequired: Validator; - } + type Requireable = PropTypes.Requireable; - type ValidationMap = {[K in keyof T]?: Validator }; + type ValidationMap = PropTypes.ValidationMap; interface ReactPropTypes { - any: Requireable; - array: Requireable; - bool: Requireable; - func: Requireable; - number: Requireable; - object: Requireable; - string: Requireable; - node: Requireable; - element: Requireable; - instanceOf(expectedClass: {}): Requireable; - oneOf(types: any[]): Requireable; - oneOfType(types: Array>): Requireable; - arrayOf(type: Validator): Requireable; - objectOf(type: Validator): Requireable; - shape(type: ValidationMap): Requireable; + any: typeof PropTypes.any; + array: typeof PropTypes.array; + bool: typeof PropTypes.bool; + func: typeof PropTypes.func; + number: typeof PropTypes.number; + object: typeof PropTypes.object; + string: typeof PropTypes.string; + node: typeof PropTypes.node; + element: typeof PropTypes.element; + instanceOf: typeof PropTypes.instanceOf; + oneOf: typeof PropTypes.oneOf; + oneOfType: typeof PropTypes.oneOfType; + arrayOf: typeof PropTypes.arrayOf; + objectOf: typeof PropTypes.objectOf; + shape: typeof PropTypes.shape; } // @@ -2282,6 +2281,21 @@ declare namespace React { } } +// Declared props take priority over inferred props +// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened +type MergePropTypes = P & Pick>; + +// Any prop that has a default prop becomes optional, but its type is unchanged +// Undeclared default props are augmented into the resulting allowable attributes +// If declared props have indexed properties, ignore default props entirely as keyof gets widened +// Wrap in an outer-level conditional type to allow distribution over props that are unions +type Defaultize = P extends any + ? string extends keyof P ? P : + & Pick> + & Partial>> + & Partial>> + : never; + declare global { namespace JSX { // tslint:disable-next-line:no-empty-interface @@ -2292,6 +2306,14 @@ declare global { interface ElementAttributesProperty { props: {}; } interface ElementChildrenAttribute { children: {}; } + type LibraryManagedAttributes = C extends { propTypes: infer T; defaultProps: infer D; } + ? Defaultize>, D> + : C extends { propTypes: infer T; } + ? MergePropTypes> + : C extends { defaultProps: infer D; } + ? Defaultize + : P; + // tslint:disable-next-line:no-empty-interface interface IntrinsicAttributes extends React.Attributes { } // tslint:disable-next-line:no-empty-interface diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 227ba5721d..a78a480199 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -1,6 +1,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import * as ReactDOMServer from "react-dom/server"; +import * as PropTypes from "prop-types"; import createFragment = require("react-addons-create-fragment"); import CSSTransitionGroup = require("react-addons-css-transition-group"); import * as LinkedStateMixin from "react-addons-linked-state-mixin"; @@ -15,12 +16,12 @@ import * as DOM from "react-dom-factories"; interface Props extends React.Attributes { hello: string; - world?: string; + world?: string | null; foo: number; } interface State { - inputValue?: string; + inputValue?: string | null; seconds?: number; } @@ -29,7 +30,7 @@ interface Snapshot { } interface Context { - someValue?: string; + someValue?: string | null; } interface ChildContext { @@ -117,15 +118,18 @@ declare const container: Element; class ModernComponent extends React.Component implements MyComponent, React.ChildContextProvider { static propTypes: React.ValidationMap = { - foo: (() => null) as React.Validator + hello: PropTypes.string.isRequired, + world: PropTypes.string, + foo: PropTypes.number.isRequired, + key: > PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }; static contextTypes: React.ValidationMap = { - someValue: (() => null) as React.Validator + someValue: PropTypes.string }; static childContextTypes: React.ValidationMap = { - someOtherValue: (() => null) as React.Validator + someOtherValue: PropTypes.string.isRequired }; context: Context; @@ -156,7 +160,7 @@ class ModernComponent extends React.Component return DOM.div(null, DOM.input({ ref: input => this._input = input, - value: this.state.inputValue + value: this.state.inputValue ? this.state.inputValue : undefined }), DOM.input({ onChange: event => console.log(event.target) diff --git a/types/react/test/managedAttributes.tsx b/types/react/test/managedAttributes.tsx new file mode 100644 index 0000000000..56466e1cc8 --- /dev/null +++ b/types/react/test/managedAttributes.tsx @@ -0,0 +1,160 @@ +interface LeaveMeAloneDtslint { foo: string; } +// // Re-enable when we move @types/react to TS 3.0 + +// import * as React from 'react'; +// import * as PropTypes from 'prop-types'; + +// interface Props { +// bool?: boolean +// fnc: () => any +// node?: React.ReactNode +// num?: number +// reqNode: NonNullable +// str: string +// } + +// const propTypes = { +// bool: PropTypes.bool, +// fnc: PropTypes.func.isRequired, +// node: PropTypes.node, +// num: PropTypes.number, +// str: PropTypes.string.isRequired, +// extraStr: PropTypes.string.isRequired, +// extraNum: PropTypes.number +// }; + +// const defaultProps = { +// fnc: function() { return 'abc' } as () => any, +// extraBool: false, +// reqNode: 'text_node' as React.ReactNode +// }; + +// class AnnotatedPropTypesAndDefaultProps extends React.Component { +// static propTypes = propTypes; +// static defaultProps = defaultProps; +// } + +// const annotatedPropTypesAndDefaultPropsTests = [ +// // $ExpectError +// , // str and extraStr are required +// , +// // $ExpectError +// , // num type mismatch +// } +// num={0} +// reqNode={} +// str='abc' +// /> +// ]; + +// class UnannotatedPropTypesAndDefaultProps extends React.Component { +// static propTypes = propTypes; +// static defaultProps = defaultProps; +// } + +// const unannotatedPropTypesAndDefaultPropsTests = [ +// // $ExpectError +// , // stra and extraStr are required +// , +// // $ExpectError +// , // extraBool type mismatch +// } +// num={0} +// reqNode={} +// str='abc' +// /> +// ]; + +// class AnnotatedPropTypes extends React.Component { +// static propTypes = propTypes; +// } + +// const annotatedPropTypesTests = [ +// // $ExpectError +// , // str, extraStr, reqNode and fnc are required +// } />, +// // $ExpectError +// } extraBool={false} />, // extraBool doesn't exist +// // $ExpectError +// } num='abc' />, // num type mismatch +// } +// num={0} +// reqNode={} +// str='abc' +// /> +// ]; + +// class UnannotatedPropTypes extends React.Component { +// static propTypes = propTypes; +// } + +// const unannotatedPropTypesTests = [ +// // $ExpectError +// , // str, extraStr and fnc are required +// , +// // $ExpectError +// } />, // reqNode doesn't exist +// // $ExpectError +// } num='abc' />, // num type mismatch +// } +// num={0} +// str='abc' +// /> +// ]; + +// class AnnotatedDefaultProps extends React.Component { +// static defaultProps = defaultProps; +// } + +// const annotatedDefaultPropsTests = [ +// // $ExpectError +// , // str is required +// , +// } />, +// // $ExpectError +// { }} />, // str type mismatch +// +// ]; + +// class UnannotatedDefaultProps extends React.Component { +// static defaultProps = defaultProps; +// } + +// const unannotatedDefaultPropsTests = [ +// , +// } +// /> +// ]; diff --git a/types/react/tsconfig.json b/types/react/tsconfig.json index 2bc92c4894..b666fac305 100644 --- a/types/react/tsconfig.json +++ b/types/react/tsconfig.json @@ -3,7 +3,8 @@ "index.d.ts", "test/index.ts", "test/tsx.tsx", - "test/cssProperties.tsx" + "test/cssProperties.tsx", + "test/managedAttributes.tsx" ], "compilerOptions": { "module": "commonjs", diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts index 939e26c57a..65f00c258f 100644 --- a/types/react/v15/index.d.ts +++ b/types/react/v15/index.d.ts @@ -13,7 +13,7 @@ // Dovydas Navickas // Stéphane Goetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /* Known Problems & Workarounds diff --git a/types/react/v15/test/index.ts b/types/react/v15/test/index.ts index 45894cb397..6735e64eeb 100644 --- a/types/react/v15/test/index.ts +++ b/types/react/v15/test/index.ts @@ -256,7 +256,7 @@ const markup: string = ReactDOMServer.renderToStaticMarkup(element); const notValid: boolean = React.isValidElement(props); // false const isValid = React.isValidElement(element); // true let domNode = ReactDOM.findDOMNode(component); -domNode = ReactDOM.findDOMNode(domNode as Element); +domNode = ReactDOM.findDOMNode(domNode); // // React Elements diff --git a/types/react/v15/tsconfig.json b/types/react/v15/tsconfig.json index f9c13ee9f2..d3eb40aae7 100644 --- a/types/react/v15/tsconfig.json +++ b/types/react/v15/tsconfig.json @@ -12,9 +12,8 @@ "dom" ], "paths": { - "react": [ - "react/v15" - ] + "react": ["react/v15"], + "react-dom": ["react-dom/v15"] }, "noImplicitAny": true, "noImplicitThis": false, @@ -29,4 +28,4 @@ "forceConsistentCasingInFileNames": true, "jsx": "preserve" } -} \ No newline at end of file +} diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 49d872c902..f0ad8596ab 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -141,7 +141,7 @@ declare module 'recompose' { stateUpdaterName: TStateUpdaterName, initialState: TState | mapper ): InferableComponentEnhancerWithProps< - TOutter & stateProps, + stateProps, TOutter >; diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index 8c45ac2021..9058a10f4d 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -257,7 +257,7 @@ function testWithState() { // We can also actually provide the generic necessary const enhancer3 = withState("count", "setCount", 1); const Enhanced3 = enhancer3(props => { - return
{props.title}
; + return
{props.count}
; }); const rendered3 = ( diff --git a/types/single-spa-react/index.d.ts b/types/single-spa-react/index.d.ts index 67721695ec..82656bfaf5 100644 --- a/types/single-spa-react/index.d.ts +++ b/types/single-spa-react/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/CanopyTax/single-spa-react // Definitions by: Garrett Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import * as React from 'react'; import * as ReactDOM from 'react-dom';