Revert "react: Improve type checking of component static properties. (#30730)" (#30964)

This reverts commit 5610636ad2.
This commit is contained in:
Matt McCutchen
2018-11-30 17:26:52 -05:00
committed by John Reilly
parent e064f929bd
commit efbcbdebaf
8 changed files with 235 additions and 225 deletions

View File

@@ -24,6 +24,36 @@ export declare class ResponsiveNavigation extends Component<ResponsiveNavigation
*/
toggle(): void;
render(): JSX.Element;
static propTypes: {
breakpoint: PropTypes.Validator<any>;
alignX: PropTypes.Requireable<any>;
alignY: PropTypes.Requireable<any>;
selfAlignX: PropTypes.Requireable<any>;
selfAlignY: PropTypes.Requireable<any>;
centerAlign: PropTypes.Requireable<any>;
flexContainer: PropTypes.Requireable<any>;
flexDirRow: PropTypes.Requireable<any>;
flexDirRowRev: PropTypes.Requireable<any>;
flexDirCol: PropTypes.Requireable<any>;
flexDirColRev: PropTypes.Requireable<any>;
flexChild: PropTypes.Requireable<any>;
flexOrder: PropTypes.Requireable<any>;
flexOrderSmall: PropTypes.Requireable<any>;
flexOrderMedium: PropTypes.Requireable<any>;
flexOrderLarge: PropTypes.Requireable<any>;
showFor: PropTypes.Requireable<any>;
showOnlyFor: PropTypes.Requireable<any>;
hideFor: PropTypes.Requireable<any>;
hideOnlyFor: PropTypes.Requireable<any>;
isHidden: PropTypes.Requireable<any>;
isInvisible: PropTypes.Requireable<any>;
showForLandscape: PropTypes.Requireable<any>;
showForPortrait: PropTypes.Requireable<any>;
showForSr: PropTypes.Requireable<any>;
showOnFocus: PropTypes.Requireable<any>;
isClearfix: PropTypes.Requireable<any>;
float: PropTypes.Requireable<any>;
};
static defaultProps: {
breakpoint: number;
};

View File

@@ -67,6 +67,9 @@ export type MenuProps<OptionType> = CommonProps<OptionType> & {
export function menuCSS(state: MenuState): React.CSSProperties;
export class Menu<OptionType> extends Component<MenuProps<OptionType>, MenuState> {
static contextTypes: {
getPortalPlacement: (state: MenuState) => void,
};
getPlacement: (ref: ElementRef<any>) => void;
getState: () => MenuProps<OptionType> & MenuState;
}
@@ -143,6 +146,9 @@ interface PortalStyleArgs {
export function menuPortalCSS(args: PortalStyleArgs): React.CSSProperties;
export class MenuPortal<OptionType> extends Component<MenuPortalProps<OptionType>, MenuPortalState> {
static childContextTypes: {
getPortalPlacement: (state: MenuState) => void,
};
getChildContext(): {
getPortalPlacement: (state: MenuState) => void;
};

View File

@@ -18,12 +18,7 @@ const NoOptionsMessage = (props: any) => {
export default class CustomNoOptionsMessage extends React.Component {
render() {
return (
// Without the type argument, `OptionType` is inferred as `never` from the
// `options` attribute of type `never[]`, and `Select.defaultProps` (of
// type `Props<any>`) fails to be assignable to the instantiated props
// type, `Props<never>`. This issue shouldn't come up in real code where
// the `options` attribute isn't a literal empty array.
<Select<{ label: string; value: string }>
<Select
isClearable
components={{ NoOptionsMessage }}
styles={{ noOptionsMessage: (base: any) => ({ ...base, ...msgStyles }) }}

View File

@@ -30,7 +30,7 @@ export type ListProps = GridCoreProps & {
/** Height constraint for list (determines how many actual rows are rendered) */
height: number;
/** Optional renderer to be used in place of rows when rowCount is 0 */
noRowsRenderer?: () => JSX.Element | null;
noRowsRenderer?: () => JSX.Element;
/**
* Callback invoked with information about the slice of rows that were just rendered.
* ({ startIndex, stopIndex }): void

View File

@@ -152,6 +152,26 @@ export type ColumnProps = {
width: number;
};
export class Column extends Component<ColumnProps> {
static propTypes: {
"aria-label": Requireable<string>;
cellDataGetter: Requireable<TableCellDataGetter>;
cellRenderer: Requireable<TableCellRenderer>;
className: Requireable<string>;
columnData: Requireable<object>;
dataKey: Validator<string>;
disableSort: Requireable<boolean>;
flexGrow: Requireable<number>;
flexShrink: Requireable<number>;
headerClassName: Requireable<string>;
headerRenderer: Validator<TableHeaderRowRenderer>;
label: Requireable<string>;
maxWidth: Requireable<number>;
minWidth: Requireable<number>;
style: Requireable<React.CSSProperties>;
width: Validator<number>;
id: Requireable<string>;
};
static defaultProps: {
cellDataGetter: TableCellDataGetter;
cellRenderer: TableCellRenderer;
@@ -358,6 +378,63 @@ export const SortIndicator: React.StatelessComponent<{
* This component expects explicit width, height, and padding parameters.
*/
export class Table extends PureComponent<TableProps> {
static propTypes: {
"aria-label": Requireable<string>;
autoHeight: Requireable<boolean>;
children: Validator<Column>;
className: Requireable<string>;
disableHeader: Requireable<boolean>;
estimatedRowSize: Validator<number>;
gridClassName: Requireable<string>;
gridStyle: Requireable<React.CSSProperties>;
headerClassName: Requireable<string>;
headerHeight: Validator<number>;
headerRowRenderer: Requireable<TableHeaderRowRenderer>;
headerStyle: Requireable<React.CSSProperties>;
height: Validator<number>;
id: Requireable<string>;
noRowsRenderer: Requireable<() => JSX.Element>;
onHeaderClick: Requireable<
(params: HeaderMouseEventHandlerParams) => void
>;
onRowClick: Requireable<(params: RowMouseEventHandlerParams) => void>;
onRowDoubleClick: Requireable<
(params: RowMouseEventHandlerParams) => void
>;
onRowMouseOut: Requireable<
(params: RowMouseEventHandlerParams) => void
>;
onRowMouseOver: Requireable<
(params: RowMouseEventHandlerParams) => void
>;
onRowsRendered: Requireable<
(params: RowMouseEventHandlerParams) => void
>;
onScroll: Requireable<(params: ScrollEventData) => void>;
overscanRowCount: Validator<number>;
rowClassName: Requireable<string | ((params: Index) => string)>;
rowGetter: Validator<(params: Index) => any>;
rowHeight: Validator<number | ((params: Index) => number)>;
rowCount: Validator<number>;
rowRenderer: Requireable<(props: TableRowProps) => React.ReactNode>;
rowStyle: Validator<
React.CSSProperties | ((params: Index) => React.CSSProperties)
>;
scrollToAlignment: Validator<Alignment>;
scrollToIndex: Validator<number>;
scrollTop: Requireable<number>;
sort: Requireable<
(
params: { sortBy: string; sortDirection: SortDirectionType }
) => void
>;
sortBy: Requireable<string>;
sortDirection: Validator<SortDirectionType>;
style: Requireable<React.CSSProperties>;
tabIndex: Requireable<number>;
width: Validator<number>;
};
static defaultProps: {
disableHeader: false;
estimatedRowSize: 30;
@@ -368,7 +445,7 @@ export class Table extends PureComponent<TableProps> {
onScroll: () => null;
overscanRowCount: 10;
rowRenderer: TableRowRenderer;
headerRowRenderer: TableHeaderRowRenderer;
headerRowRenderer: TableHeaderRenderer;
rowStyle: {};
scrollToAlignment: "auto";
scrollToIndex: -1;

126
types/react/index.d.ts vendored
View File

@@ -421,34 +421,6 @@ declare namespace React {
refs: {
[key: string]: ReactInstance
};
// Static properties copied from ComponentClass interface.
/**
* The validity of the type of `propTypes` cannot be checked
* automatically at the definition of a component class because the
* required type depends on `P`. We recommend checking it using
* `asPropTypes` from the `react-typescript-helpers` package. If you
* don't do that, then the type will still be checked by
* JSX.LibraryManagedAttributes every time the component is used,
* assuming you use TypeScript 3.0 or newer.
*/
// Note: `propTypes` and `defaultProps` need to be `any` so that a
// component class that does not redeclare them is assignable to
// `ComponentClass<P>`.
static propTypes?: any;
static contextTypes?: ValidationMap<any>;
static childContextTypes?: ValidationMap<any>;
/**
* The validity of the type of `defaultProps` cannot be checked
* automatically at the definition of a component class because the
* required type depends on `P`. We recommend checking it using
* `asDefaultProps` from the `react-typescript-helpers` package. If you
* don't do that, then the type will still be checked by
* JSX.LibraryManagedAttributes every time the component is used,
* assuming you use TypeScript 3.0 or newer.
*/
static defaultProps?: any;
static displayName?: string;
}
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> { }
@@ -2664,77 +2636,31 @@ declare namespace React {
*/
componentStack: string;
}
const Invalid_propTypes: unique symbol;
/**
* Dummy interface that is intersected into the props type of a component on
* use to generate an error if the component's `propTypes` static property
* is invalid. In most cases, you can get more information about the
* problem with the `propTypes` by trying to assign the component to a
* variable of type `React.ComponentType<P>` where `P` is the appropriate
* props type. You can bypass the type checking of `propTypes` by defining
* a static property named `bypassPropTypesTypecheck`.
*/
interface Invalid_propTypes<P, T> {
[Invalid_propTypes]: never;
}
const Invalid_defaultProps: unique symbol;
/**
* Dummy interface that is intersected into the props type of a component on
* use to generate an error if the component's `defaultProps` static
* property is invalid. In most cases, you can get more information about
* the problem with the `defaultProps` by trying to assign the component to
* a variable of type `React.ComponentType<P>` where `P` is the appropriate
* props type. You can bypass the type checking of `defaultProps` by
* defining a static property named `bypassDefaultPropsTypecheck`.
*/
interface Invalid_defaultProps<P, D> {
[Invalid_defaultProps]: never;
}
// For a component class, the P passed to JSX.LibraryManagedAttributes is
// based on the `props` property and includes `children` regardless of
// whether the original props type (the `P` type argument to
// React.Component) does. However, it's common for component classes not
// to list `children` in the `propTypes` if the original props type did not
// include `children`. We accommodate that here by making the validator for
// `children` optional.
type ValidationMapWithOptionalChildren<P> =
ValidationMap<Pick<P, Exclude<keyof P, "children">>> &
Partial<ValidationMap<Pick<P, Extract<keyof P, "children">>>>;
// Explicitly check for excess properties in CheckPropTypes and
// CheckDefaultProps because by the time we get to
// JSX.LibraryManagedAttributes, we have lost the opportunity to do an
// excess properties check on the original object literal.
type CheckPropTypes<P, T> =
// This condition attempts to single out `T = any`, which needs to bypass the rest of the check
// because `keyof T` would come out as not extending `keyof P`.
T extends typeof Invalid_propTypes ? {} :
[keyof T, T] extends [keyof P, ValidationMapWithOptionalChildren<P>] ? {} : Invalid_propTypes<P, T>;
type CheckDefaultProps<P, D> =
D extends typeof Invalid_defaultProps ? {} :
[keyof D, D] extends [keyof P, Partial<P>] ? {} : Invalid_defaultProps<P, D>;
// Any prop that has a default prop becomes optional, but its type is unchanged
// 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>>>
: never;
type ReactManagedAttributes<C, P> =
(C extends { propTypes: infer T; }
? (C extends { bypassPropTypesTypecheck: {}; } ? {} : CheckPropTypes<P, T>) : {}) &
(C extends { defaultProps: infer D; }
? (C extends { bypassDefaultPropsTypecheck: {}; } ? {} : CheckDefaultProps<P, D>) & Defaultize<P, D> : P);
}
// 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;
type ReactManagedAttributes<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;
declare global {
namespace JSX {
// tslint:disable-next-line:no-empty-interface
@@ -2749,9 +2675,9 @@ declare global {
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
? React.ReactManagedAttributes<U, P>
: React.ReactManagedAttributes<T, P>
: React.ReactManagedAttributes<C, P>;
? ReactManagedAttributes<U, P>
: ReactManagedAttributes<T, P>
: ReactManagedAttributes<C, P>;
// tslint:disable-next-line:no-empty-interface
interface IntrinsicAttributes extends React.Attributes { }

View File

@@ -1,18 +1,14 @@
interface LeaveMeAloneDtslint { foo: string; }
// Re-enable when we move @types/react to TS 3.0 (except for the tests marked as
// requiring TS >= 3.2)
//
// In the meantime, these tests can be run manually by uncommenting the code
// below and running `dtslint --onlyTestTsNext`.
// // 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 | null;
// bool?: boolean;
// fnc: () => any;
// node?: React.ReactNode;
// num?: number | null;
// num?: number;
// reqNode: NonNullable<React.ReactNode>;
// str: string;
// }
@@ -22,12 +18,14 @@ interface LeaveMeAloneDtslint { foo: string; }
// fnc: PropTypes.func.isRequired,
// node: PropTypes.node,
// num: PropTypes.number,
// reqNode: PropTypes.node.isRequired,
// str: PropTypes.string.isRequired,
// extraStr: PropTypes.string.isRequired,
// extraNum: PropTypes.number
// };
// const defaultProps = {
// fnc: (() => 'abc') as () => any,
// extraBool: false,
// reqNode: 'text_node' as NonNullable<React.ReactNode>
// };
@@ -38,12 +36,39 @@ interface LeaveMeAloneDtslint { foo: string; }
// const annotatedPropTypesAndDefaultPropsTests = [
// // $ExpectError
// <AnnotatedPropTypesAndDefaultProps />, // str is required
// <AnnotatedPropTypesAndDefaultProps str='abc' />,
// <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}
@@ -58,14 +83,16 @@ interface LeaveMeAloneDtslint { foo: string; }
// const annotatedPropTypesTests = [
// // $ExpectError
// <AnnotatedPropTypes />, // str, reqNode and fnc are required
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} />,
// <AnnotatedPropTypes />, // str, extraStr, reqNode and fnc are required
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} />,
// // $ExpectError
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} extraBool={false} />, // extraBool doesn't exist
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} extraBool={false} />, // extraBool doesn't exist
// // $ExpectError
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} num='abc' />, // num type mismatch
// <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}
@@ -74,6 +101,29 @@ interface LeaveMeAloneDtslint { foo: string; }
// />
// ];
// 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;
// }
@@ -87,6 +137,7 @@ interface LeaveMeAloneDtslint { foo: string; }
// <AnnotatedDefaultProps str={() => { }} />, // str type mismatch
// <AnnotatedDefaultProps
// bool={true}
// extraBool={false}
// fnc={console.log}
// node={null}
// num={0}
@@ -95,15 +146,31 @@ interface LeaveMeAloneDtslint { foo: string; }
// />
// ];
// class UnannotatedDefaultProps extends React.Component {
// static defaultProps = defaultProps;
// }
// const unannotatedDefaultPropsTests = [
// <UnannotatedDefaultProps />,
// <UnannotatedDefaultProps
// extraBool={true}
// fnc={console.log}
// reqNode={<span />}
// />
// ];
// class ComponentWithNoDefaultProps extends React.Component<Props> {}
// function FunctionalComponent(props: Props) { return <>{props.reqNode}</>; }
// function FunctionalComponent(props: Props) { return <>{props.reqNode}</> }
// FunctionalComponent.defaultProps = defaultProps;
// const functionalComponentTests = [
// // $ExpectError
// <FunctionalComponent />,
// // NOTE: This test requires TypeScript >= 3.2, which honors JSX.LibraryManagedAttributes for function components.
// // This is possibly a bug/limitation of TS
// // Even if JSX.LibraryManagedAttributes returns the correct type, it doesn't seem to work with non-classes
// // This also doesn't work with things typed React.SFC<P> because defaultProps will always be Partial<P>
// // $ExpectError
// <FunctionalComponent str='' />
// ];
@@ -115,28 +182,27 @@ interface LeaveMeAloneDtslint { foo: string; }
// const memoTests = [
// // $ExpectError
// <MemoFunctionalComponent />,
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
// // $ExpectError won't work as long as FunctionalComponent doesn't work either
// <MemoFunctionalComponent str='abc' />,
// // $ExpectError
// <MemoAnnotatedDefaultProps />,
// <AnnotatedDefaultProps str='abc' />,
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
// // $ExpectError this doesn't work despite JSX.LibraryManagedAttributes returning the correct type
// <MemoAnnotatedDefaultProps str='abc' />,
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
// // $ExpectError won't work as long as FunctionalComponent doesn't work either
// <LazyMemoFunctionalComponent str='abc' />,
// // $ExpectError
// <LazyMemoAnnotatedDefaultProps />,
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
// // $ExpectError this doesn't work despite JSX.LibraryManagedAttributes returning the correct type
// <LazyMemoAnnotatedDefaultProps str='abc' />
// ];
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
// type AnnotatedDefaultPropsLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof AnnotatedDefaultProps, Props>;
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
// // $ExpectType AnnotatedDefaultPropsLibraryManagedAttributes
// type FunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof FunctionalComponent, Props>;
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
// // $ExpectType FunctionalComponentLibraryManagedAttributes
// type MemoFunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof MemoFunctionalComponent, Props>;
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
// // $ExpectType FunctionalComponentLibraryManagedAttributes
// type LazyMemoFunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof LazyMemoFunctionalComponent, Props>;
// const ForwardRef = React.forwardRef((props: Props, ref: React.Ref<ComponentWithNoDefaultProps>) => (
@@ -152,97 +218,7 @@ interface LeaveMeAloneDtslint { foo: string; }
// reqNode={<span />}
// str=''
// />,
// // the type of ForwardRef.defaultProps stays Partial<P> anyway even if assigned
// // $ExpectError
// // same bug as MemoFunctionalComponent and React.SFC-typed things
// // $ExpectError the type of ForwardRef.defaultProps stays Partial<P> anyway even if assigned
// <ForwardRef str='abc' />
// ];
// const wrongDefaultProps = {
// fnc: 42
// };
// class WrongDefaultPropsComponent extends React.Component<Props> {
// static defaultProps = wrongDefaultProps;
// }
// const wrongDefaultPropsComponentTests = [
// // $ExpectError
// <WrongDefaultPropsComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// // $ExpectError
// const investigateWrongDefaultPropsComponent: React.ComponentType<Props> = WrongDefaultPropsComponent;
// const excessDefaultProps = {
// another: 43
// };
// class ExcessDefaultPropsComponent extends React.Component<Props> {
// static defaultProps = excessDefaultProps;
// }
// const excessDefaultPropsComponentTests = [
// // $ExpectError
// <ExcessDefaultPropsComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// // $ExpectError
// const investigateExcessDefaultPropsComponent: React.ComponentType<Props> = ExcessDefaultPropsComponent;
// const wrongPropTypes = {
// bool: PropTypes.bool,
// fnc: PropTypes.number.isRequired,
// node: PropTypes.node,
// num: PropTypes.number,
// reqNode: PropTypes.node.isRequired,
// str: PropTypes.string.isRequired,
// };
// class WrongPropTypesComponent extends React.Component<Props> {
// static propTypes = wrongPropTypes;
// }
// const wrongPropTypesComponentTests = [
// // $ExpectError
// <WrongPropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// const incompletePropTypes = {
// bool: PropTypes.bool,
// node: PropTypes.node,
// num: PropTypes.number,
// reqNode: PropTypes.node.isRequired,
// str: PropTypes.string.isRequired,
// };
// class IncompletePropTypesComponent extends React.Component<Props> {
// static propTypes = incompletePropTypes;
// }
// const incompletePropTypesComponentTests = [
// // $ExpectError
// <IncompletePropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// const excessPropTypes = {
// another: PropTypes.number.isRequired,
// bool: PropTypes.bool,
// fnc: PropTypes.func.isRequired,
// node: PropTypes.node,
// num: PropTypes.number,
// reqNode: PropTypes.node.isRequired,
// str: PropTypes.string.isRequired,
// };
// class ExcessPropTypesComponent extends React.Component<Props> {
// static propTypes = excessPropTypes;
// }
// const ExcessPropTypesComponentTests = [
// // $ExpectError
// <ExcessPropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// class WrongDefaultPropsSuppressedComponent extends React.Component<Props> {
// static defaultProps = wrongDefaultProps;
// static bypassDefaultPropsTypecheck = true;
// }
// const wrongDefaultPropsSuppressedComponentTests = [
// <WrongDefaultPropsSuppressedComponent fnc={() => undefined} reqNode="text" str="str" />
// ];
// class WrongPropTypesSuppressedComponent extends React.Component<Props> {
// static propTypes = wrongPropTypes;
// static bypassPropTypesTypecheck = true;
// }
// const wrongPropTypesSuppressedComponentTests = [
// <WrongPropTypesSuppressedComponent fnc={() => undefined} reqNode="text" str="str" />
// ];

View File

@@ -40,7 +40,7 @@ export interface ThemeListener<C extends string> {
callback: (theme: Theme) => void
): SubscriptionId;
unsubscribe(context: ContextWithTheme<C>, id: SubscriptionId): void;
contextTypes: React.ValidationMap<ContextWithTheme<C>>;
contextTypes: React.ValidationMap<C>;
}
/**
* ThemeListener for the default channel