mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
[react] add library managed attributes and upgrade TS requirement to 2.8 (#27901)
* feat(react): add library managed attributes and upgrade to 2.8 * fix broken tests * fix lint errors
This commit is contained in:
committed by
John Reilly
parent
5f81770afb
commit
1d9679b2dc
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://facebook.github.io/react/
|
||||
// Definitions by: John Gozde <https://github.com/jgoz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ComponentSpec, ClassicComponentClass } from "react";
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/pinterest/gestalt
|
||||
// Definitions by: Nicolás Serrano Arévalo <https://github.com/serranoarevalo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
<C x={1}/>;
|
||||
<C x={1} />;
|
||||
|
||||
const D = hoistNonReactStatics(A, B, { a: true, b: true });
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/salvoravida/react-adal#readme
|
||||
// Definitions by: Dmitry Korolev <https://github.com/dkorolev1>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import 'react-addons-transition-group';
|
||||
import { ComponentClass, CSSTransitionGroupProps } from 'react';
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Mixin } from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Mixin } from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Component } from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { AbstractView, Component, ComponentClass,
|
||||
ReactElement, ReactInstance, ClassType,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ComponentClass, TransitionGroupProps } from 'react';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/davidtheclark/react-aria-modal#readme
|
||||
// Definitions by: forabi <https://github.com/forabi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import React = require('react');
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://facebook.github.io/react/
|
||||
// Definitions by: John Gozde <https://github.com/jgoz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export as namespace ReactDOMFactories;
|
||||
export = ReactDOMFactories;
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
// MartynasZilinskas <https://github.com/MartynasZilinskas>
|
||||
// Josh Rutherford <https://github.com/theruther4d>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export as namespace ReactDOM;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// Microsoft <https://microsoft.com>
|
||||
// MartynasZilinskas <https://github.com/MartynasZilinskas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export as namespace ReactDOM;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/chrisjpatty/react-dragtastic#readme
|
||||
// Definitions by: Nicolás Scarcella <https://github.com/nscarcella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ReactNode, Component, MouseEventHandler, TouchEventHandler } from 'react';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/matteocng/react-flag-icon-css#readme
|
||||
// Definitions by: Jon Freedman <https://github.com/jonfreedman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as CSS from 'csstype';
|
||||
import { PureComponent, ReactNode } from 'react';
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/akiran/react-highlight
|
||||
// Definitions by: Josh Goldberg <https://github.com/joshuakgoldberg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/JedWatson/react-input-autosize#readme
|
||||
// Definitions by: Jason Unger <https://github.com/jsonunger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
@@ -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<SomeComponentProps>
|
||||
});
|
||||
|
||||
class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlProps> {
|
||||
static propTypes: React.ValidationMap<any> = {
|
||||
intl: intlShape.isRequired
|
||||
static propTypes: React.ValidationMap<SomeComponentProps & InjectedIntlProps> = {
|
||||
intl: intlShape.isRequired,
|
||||
className: PropTypes.string.isRequired
|
||||
};
|
||||
render(): React.ReactElement<{}> {
|
||||
const intl = this.props.intl;
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/kadirahq/react-no-ssr
|
||||
// Definitions by: Rafał Filipek <https://github.com/rafalfilipek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/plotly/react-plotly.js#readme
|
||||
// Definitions by: Jon Freedman <https://github.com/jonfreedman>
|
||||
// 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';
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/tajo/react-portal#readme
|
||||
// Definitions by: Shun Takahashi <https://github.com/shuntksh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/JodusNodus/react-qr-reader
|
||||
// Definitions by: David Kevork <https://github.com/davidkevork>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
|
||||
@@ -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%',
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@
|
||||
// Endurance Idehen <https://github.com/endurance>
|
||||
// Guillaume Chartier <https://github.com/RCGuillaume>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+43
-21
@@ -19,11 +19,12 @@
|
||||
// Olivier Pascal <https://github.com/pascaloliv>
|
||||
// Martin Hochel <https://github.com/hotell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference path="global.d.ts" />
|
||||
|
||||
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<T> = { bivarianceHack(object: T, key: string, componentName: string, ...rest: any[]): Error | null }["bivarianceHack"];
|
||||
type Validator<T> = PropTypes.Validator<T>;
|
||||
|
||||
interface Requireable<T> extends Validator<T> {
|
||||
isRequired: Validator<T>;
|
||||
}
|
||||
type Requireable<T> = PropTypes.Requireable<T>;
|
||||
|
||||
type ValidationMap<T> = {[K in keyof T]?: Validator<T> };
|
||||
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
||||
|
||||
interface ReactPropTypes {
|
||||
any: Requireable<any>;
|
||||
array: Requireable<any>;
|
||||
bool: Requireable<any>;
|
||||
func: Requireable<any>;
|
||||
number: Requireable<any>;
|
||||
object: Requireable<any>;
|
||||
string: Requireable<any>;
|
||||
node: Requireable<any>;
|
||||
element: Requireable<any>;
|
||||
instanceOf(expectedClass: {}): Requireable<any>;
|
||||
oneOf(types: any[]): Requireable<any>;
|
||||
oneOfType(types: Array<Validator<any>>): Requireable<any>;
|
||||
arrayOf(type: Validator<any>): Requireable<any>;
|
||||
objectOf(type: Validator<any>): Requireable<any>;
|
||||
shape(type: ValidationMap<any>): Requireable<any>;
|
||||
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, T> = P & Pick<T, Exclude<keyof T, keyof P>>;
|
||||
|
||||
// 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, D> = P extends any
|
||||
? string extends keyof P ? P :
|
||||
& Pick<P, Exclude<keyof P, keyof D>>
|
||||
& Partial<Pick<P, Extract<keyof P, keyof D>>>
|
||||
& Partial<Pick<D, Exclude<keyof D, keyof P>>>
|
||||
: 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, P> = C extends { propTypes: infer T; defaultProps: infer D; }
|
||||
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
||||
: C extends { propTypes: infer T; }
|
||||
? MergePropTypes<P, PropTypes.InferProps<T>>
|
||||
: C extends { defaultProps: infer D; }
|
||||
? Defaultize<P, D>
|
||||
: P;
|
||||
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface IntrinsicAttributes extends React.Attributes { }
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
|
||||
@@ -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<Props, State, Snapshot>
|
||||
implements MyComponent, React.ChildContextProvider<ChildContext> {
|
||||
static propTypes: React.ValidationMap<Props> = {
|
||||
foo: (() => null) as React.Validator<Props>
|
||||
hello: PropTypes.string.isRequired,
|
||||
world: PropTypes.string,
|
||||
foo: PropTypes.number.isRequired,
|
||||
key: <PropTypes.Validator<string | number | undefined>> PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
};
|
||||
|
||||
static contextTypes: React.ValidationMap<Context> = {
|
||||
someValue: (() => null) as React.Validator<Context>
|
||||
someValue: PropTypes.string
|
||||
};
|
||||
|
||||
static childContextTypes: React.ValidationMap<ChildContext> = {
|
||||
someOtherValue: (() => null) as React.Validator<ChildContext>
|
||||
someOtherValue: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
context: Context;
|
||||
@@ -156,7 +160,7 @@ class ModernComponent extends React.Component<Props, State, Snapshot>
|
||||
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)
|
||||
|
||||
@@ -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<React.ReactNode>
|
||||
// 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<Props> {
|
||||
// static propTypes = propTypes;
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const annotatedPropTypesAndDefaultPropsTests = [
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypesAndDefaultProps />, // str and extraStr are required
|
||||
// <AnnotatedPropTypesAndDefaultProps extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypesAndDefaultProps num='abc' />, // num type mismatch
|
||||
// <AnnotatedPropTypesAndDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={true}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<span />}
|
||||
// num={0}
|
||||
// reqNode={<span />}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedPropTypesAndDefaultProps extends React.Component {
|
||||
// static propTypes = propTypes;
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const unannotatedPropTypesAndDefaultPropsTests = [
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypesAndDefaultProps />, // stra and extraStr are required
|
||||
// <UnannotatedPropTypesAndDefaultProps extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypesAndDefaultProps extraBool={0} />, // extraBool type mismatch
|
||||
// <UnannotatedPropTypesAndDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={true}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<span />}
|
||||
// num={0}
|
||||
// reqNode={<span />}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class AnnotatedPropTypes extends React.Component<Props> {
|
||||
// static propTypes = propTypes;
|
||||
// }
|
||||
|
||||
// const annotatedPropTypesTests = [
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes />, // str, extraStr, reqNode and fnc are required
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} />,
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} extraBool={false} />, // extraBool doesn't exist
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} num='abc' />, // num type mismatch
|
||||
// <AnnotatedPropTypes
|
||||
// bool={false}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<React.Fragment />}
|
||||
// num={0}
|
||||
// reqNode={<React.Fragment />}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedPropTypes extends React.Component {
|
||||
// static propTypes = propTypes;
|
||||
// }
|
||||
|
||||
// const unannotatedPropTypesTests = [
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes />, // str, extraStr and fnc are required
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} />, // reqNode doesn't exist
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} num='abc' />, // num type mismatch
|
||||
// <UnannotatedPropTypes
|
||||
// bool={false}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<React.Fragment />}
|
||||
// num={0}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class AnnotatedDefaultProps extends React.Component<Props> {
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const annotatedDefaultPropsTests = [
|
||||
// // $ExpectError
|
||||
// <AnnotatedDefaultProps />, // str is required
|
||||
// <AnnotatedDefaultProps str='abc' />,
|
||||
// <AnnotatedDefaultProps str='abc' reqNode={<span />} />,
|
||||
// // $ExpectError
|
||||
// <AnnotatedDefaultProps str={() => { }} />, // str type mismatch
|
||||
// <AnnotatedDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={false}
|
||||
// fnc={console.log}
|
||||
// node={null}
|
||||
// num={0}
|
||||
// reqNode={undefined}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedDefaultProps extends React.Component {
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const unannotatedDefaultPropsTests = [
|
||||
// <UnannotatedDefaultProps />,
|
||||
// <UnannotatedDefaultProps
|
||||
// extraBool={true}
|
||||
// fnc={console.log}
|
||||
// reqNode={<span />}
|
||||
// />
|
||||
// ];
|
||||
@@ -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",
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
// Dovydas Navickas <https://github.com/DovydasNavickas>
|
||||
// Stéphane Goetz <https://github.com/onigoetz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/*
|
||||
Known Problems & Workarounds
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -141,7 +141,7 @@ declare module 'recompose' {
|
||||
stateUpdaterName: TStateUpdaterName,
|
||||
initialState: TState | mapper<TOutter, TState>
|
||||
): InferableComponentEnhancerWithProps<
|
||||
TOutter & stateProps<TState, TStateName, TStateUpdaterName>,
|
||||
stateProps<TState, TStateName, TStateUpdaterName>,
|
||||
TOutter
|
||||
>;
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ function testWithState() {
|
||||
// We can also actually provide the generic necessary
|
||||
const enhancer3 = withState<OutterProps, number, "count", "setCount">("count", "setCount", 1);
|
||||
const Enhanced3 = enhancer3(props => {
|
||||
return <div>{props.title}</div>;
|
||||
return <div>{props.count}</div>;
|
||||
});
|
||||
const rendered3 = (
|
||||
<Enhanced3 title="foo" />
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/CanopyTax/single-spa-react
|
||||
// Definitions by: Garrett Smith <https://github.com/Garrett-Smith-iq>
|
||||
// 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';
|
||||
|
||||
Reference in New Issue
Block a user