Skip to content

Commit

Permalink
react: Constraint element type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ypresto committed Feb 27, 2017
1 parent 4f265a1 commit 7598796
Show file tree
Hide file tree
Showing 21 changed files with 142 additions and 142 deletions.
4 changes: 2 additions & 2 deletions enzyme/enzyme-tests.tsx
Expand Up @@ -34,7 +34,7 @@ namespace ShallowWrapperTest {
boolVal: boolean,
stringVal: string,
numOrStringVal: number | string,
elementWrapper: ShallowWrapper<HTMLAttributes<{}>, {}>,
elementWrapper: ShallowWrapper<HTMLAttributes<HTMLElement>, {}>,
statelessWrapper: ShallowWrapper<StatelessProps, never>;

function test_shallow_options() {
Expand Down Expand Up @@ -334,7 +334,7 @@ namespace ReactWrapperTest {
objectVal: {},
boolVal: boolean,
stringVal: string,
elementWrapper: ReactWrapper<HTMLAttributes<{}>, {}>,
elementWrapper: ReactWrapper<HTMLAttributes<HTMLElement>, {}>,
statelessWrapper: ReactWrapper<StatelessProps, never>;

function test_unmount() {
Expand Down
2 changes: 1 addition & 1 deletion enzyme/index.d.ts
Expand Up @@ -11,7 +11,7 @@
/// <reference types="cheerio" />
import { ReactElement, Component, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";

type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;
type HTMLAttributes = ReactHTMLAttributes<HTMLElement> & ReactSVGAttributes<SVGElement>;

export class ElementClass extends Component<any, any> {
}
Expand Down
2 changes: 1 addition & 1 deletion fixed-data-table/index.d.ts
Expand Up @@ -465,7 +465,7 @@ declare namespace FixedDataTable {
* />
* );
*/
export interface CellProps extends React.HTMLAttributes<Cell> {
export interface CellProps extends React.HTMLAttributes<HTMLElement> {
/**
* The row index of the cell.
*/
Expand Down
22 changes: 11 additions & 11 deletions jsnox/index.d.ts
Expand Up @@ -25,41 +25,41 @@ interface CreateElement {
/**
* Renders an HTML element from the given spec string, with children but without
* extra props.
* @param specString A string that defines a component in a way that resembles
* @param specString A string that defines a component in a way that resembles
* CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]"
* @param children A single React node (string or ReactElement) or array of nodes.
* Note that unlike with React itself, multiple children must be placed into an array.
* Note that unlike with React itself, multiple children must be placed into an array.
*/
<P>(specString: string, children: React.ReactNode): React.DOMElement<P, Element>

/**
* Renders an HTML element from the given spec string, with optional props
* Renders an HTML element from the given spec string, with optional props
* and children
* @param specString A string that defines a component in a way that resembles
* @param specString A string that defines a component in a way that resembles
* CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]"
* @param props Object of html attribute key-value pairs
* @param children A single React node (string or ReactElement) or array of nodes.
* Note that unlike with React itself, multiple children must be placed into an array.
* Note that unlike with React itself, multiple children must be placed into an array.
*/
<P>(specString: string, props?: React.HTMLAttributes<{}>, children?: React.ReactNode): React.DOMElement<P, Element>
<P>(specString: string, props?: React.HTMLAttributes<HTMLElement>, children?: React.ReactNode): React.DOMElement<P, Element>


/**
* Renders a React component, with children but no props
* @param component A plain React component (created from React.createClass()) or
* @param component A plain React component (created from React.createClass()) or
* component factory (created from React.createFactory())
* @param children A single React node (string or ReactElement) or array of nodes.
* Note that unlike with React itself, multiple children must be placed into an array.
* Note that unlike with React itself, multiple children must be placed into an array.
*/
<P>(component: React.ComponentClass<P>, children: React.ReactNode): React.ReactElement<P>

/**
/**
* Renders a React component, with optional props and children
* @param component A plain React component (created from React.createClass()) or
* @param component A plain React component (created from React.createClass()) or
* component factory (created from React.createFactory())
* @param props Props object to pass to the component
* @param children A single React node (string or ReactElement) or array of nodes.
* Note that unlike with React itself, multiple children must be placed into an array.
* Note that unlike with React itself, multiple children must be placed into an array.
*/
<P>(component: React.ComponentClass<P>, props?: P, children?: React.ReactNode): React.ReactElement<P>
}
Expand Down
32 changes: 16 additions & 16 deletions material-ui/index.d.ts
Expand Up @@ -621,13 +621,13 @@ declare namespace __MaterialUI {
focusRippleOpacity?: number;
href?: string;
keyboardFocused?: boolean;
onBlur?: React.FocusEventHandler<{}>;
onFocus?: React.FocusEventHandler<{}>;
onKeyboardFocus?: (e: React.FocusEvent<{}>, isKeyboardFocused: boolean) => void;
onKeyDown?: React.KeyboardEventHandler<{}>;
onKeyUp?: React.KeyboardEventHandler<{}>;
onBlur?: React.FocusEventHandler<T>;
onFocus?: React.FocusEventHandler<T>;
onKeyboardFocus?: (e: React.FocusEvent<T>, isKeyboardFocused: boolean) => void;
onKeyDown?: React.KeyboardEventHandler<T>;
onKeyUp?: React.KeyboardEventHandler<T>;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
onClick?: React.MouseEventHandler<T>;
style?: React.CSSProperties;
tabIndex?: number;
target?: string;
Expand All @@ -637,15 +637,15 @@ declare namespace __MaterialUI {
containerElement?: React.ReactNode | string;
}

interface EnhancedButtonProps extends React.HTMLAttributes<{}>, SharedEnhancedButtonProps<EnhancedButton> {
interface EnhancedButtonProps extends React.HTMLAttributes<HTMLElement>, SharedEnhancedButtonProps<HTMLElement> {
// container element, <button/>, or <span/>(if disabled link) is the element that get the 'other' properties
containerElement?: React.ReactNode | string;
disabled?: boolean;
}
export class EnhancedButton extends React.Component<EnhancedButtonProps, {}> {
}

interface FlatButtonProps extends React.DOMAttributes<{}>, SharedEnhancedButtonProps<FlatButton> {
interface FlatButtonProps extends React.DOMAttributes<HTMLElement>, SharedEnhancedButtonProps<HTMLElement> {
// <EnhancedButton/> is the element that get the 'other' properties
backgroundColor?: string;
disabled?: boolean;
Expand Down Expand Up @@ -696,7 +696,7 @@ declare namespace __MaterialUI {
export class RaisedButton extends React.Component<RaisedButtonProps, {}> {
}

interface FloatingActionButtonProps extends React.HTMLAttributes<{}>, SharedEnhancedButtonProps<FloatingActionButton> {
interface FloatingActionButtonProps extends React.HTMLAttributes<HTMLElement>, SharedEnhancedButtonProps<HTMLElement> {
// <EnhancedButton/> is the element that get the 'other' properties
backgroundColor?: string;
className?: string;
Expand All @@ -718,7 +718,7 @@ declare namespace __MaterialUI {
export class FloatingActionButton extends React.Component<FloatingActionButtonProps, {}> {
}

interface IconButtonProps extends React.HTMLAttributes<{}>, SharedEnhancedButtonProps<IconButton> {
interface IconButtonProps extends React.HTMLAttributes<HTMLElement>, SharedEnhancedButtonProps<HTMLElement> {
// <EnhancedButton/> is the element that get the 'other' properties
className?: string;
disableTouchRipple?: boolean;
Expand Down Expand Up @@ -945,7 +945,7 @@ declare namespace __MaterialUI {
ref?: string;
text: string;
}
interface DialogProps extends React.DOMAttributes<{}>, React.Props<Dialog> {
interface DialogProps extends React.DOMAttributes<HTMLElement>, React.Props<Dialog> {
actions?: Array<DialogAction | React.ReactElement<any>>;
/** @deprecated use a custom `actions` property instead */
actionFocus?: string;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ declare namespace __MaterialUI {
}
}

interface FontIconProps extends React.HTMLAttributes<{}>, React.Props<FontIcon> {
interface FontIconProps extends React.HTMLAttributes<HTMLElement>, React.Props<FontIcon> {
// <span/> is the element that get the 'other' properties
color?: string;
hoverColor?: string;
Expand All @@ -1036,7 +1036,7 @@ declare namespace __MaterialUI {
export class FontIcon extends React.Component<FontIconProps, {}> {
}

interface SvgIconProps extends React.SVGAttributes<{}>, React.Props<SvgIcon> {
interface SvgIconProps extends React.SVGAttributes<SVGElement>, React.Props<SvgIcon> {
// <svg/> is the element that get the 'other' properties
color?: string;
hoverColor?: string;
Expand Down Expand Up @@ -1213,7 +1213,7 @@ declare namespace __MaterialUI {
export class Overlay extends React.Component<OverlayProps, {}> {
}

interface PaperProps extends React.HTMLAttributes<{}>, React.Props<Paper> {
interface PaperProps extends React.HTMLAttributes<HTMLElement>, React.Props<Paper> {
circle?: boolean;
rounded?: boolean;
style?: React.CSSProperties;
Expand Down Expand Up @@ -1363,7 +1363,7 @@ declare namespace __MaterialUI {
namespace Switches {

// what's not commonly overridden by Checkbox, RadioButton, or Toggle
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributes<{}>, React.Props<T> {
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributes<HTMLElement>, React.Props<T> {
}

interface EnhancedSwitchProps extends CommonEnhancedSwitchProps<EnhancedSwitch> {
Expand Down Expand Up @@ -1877,7 +1877,7 @@ declare namespace __MaterialUI {
export class ToolbarSeparator extends React.Component<ToolbarSeparatorProps, {}> {
}

interface ToolbarTitleProps extends React.HTMLAttributes<{}>, React.Props<ToolbarTitle> {
interface ToolbarTitleProps extends React.HTMLAttributes<HTMLElement>, React.Props<ToolbarTitle> {
className?: string;
style?: React.CSSProperties;
text?: string;
Expand Down
2 changes: 1 addition & 1 deletion radium/index.d.ts
Expand Up @@ -43,7 +43,7 @@ declare namespace Radium {
/**
* StyleRoot component properties
*/
export interface StyleRootProps extends React.HTMLProps<StyleRoot> {
export interface StyleRootProps extends React.HTMLProps<HTMLElement> {
}
/**
* <StyleRoot />
Expand Down
2 changes: 1 addition & 1 deletion react-addons-linked-state-mixin/index.d.ts
Expand Up @@ -22,7 +22,7 @@ declare namespace LinkedStateMixin {
}

declare module 'react' {
interface HTMLAttributes<T> {
interface HTMLAttributes<T extends HTMLElement> {
checkedLink?: LinkedStateMixin.ReactLink<boolean>;
valueLink?: LinkedStateMixin.ReactLink<boolean | string | number>;
}
Expand Down
2 changes: 1 addition & 1 deletion react-addons-test-utils/index.d.ts
Expand Up @@ -127,7 +127,7 @@ declare namespace TestUtils {

export function isElementOfType<T extends HTMLElement>(
element: ReactElement<any>, type: string): element is ReactHTMLElement<T>;
export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
export function isElementOfType<P extends DOMAttributes<Element>, T extends Element>(
element: ReactElement<any>, type: string): element is DOMElement<P, T>;
export function isElementOfType<P>(
element: ReactElement<any>, type: SFC<P>): element is SFCElement<P>;
Expand Down
2 changes: 1 addition & 1 deletion react-addons-transition-group/index.d.ts
Expand Up @@ -7,7 +7,7 @@
import { ReactElement, ComponentClass, ReactType, TransitionGroupProps } from 'react';

declare module 'react' {
export interface TransitionGroupProps extends HTMLAttributes<{}> {
export interface TransitionGroupProps extends HTMLAttributes<HTMLElement> {
component?: ReactType;
className?: string;
childFactory?: (child: ReactElement<any>) => ReactElement<any>;
Expand Down

0 comments on commit 7598796

Please sign in to comment.