Improve react typings for HTML attributes, fix tests in other libraries

This commit is contained in:
Stéphane Goetz
2017-07-10 22:43:07 +02:00
parent a294aca7d4
commit a24aee6125
9 changed files with 744 additions and 356 deletions
+6 -3
View File
@@ -1128,6 +1128,7 @@ declare namespace __MaterialUI {
secondaryText?: React.ReactNode;
secondaryTextLines?: number; // 1 or 2
style?: React.CSSProperties;
value?: any;
}
export class ListItem extends React.Component<ListItemProps> {
}
@@ -1174,6 +1175,7 @@ declare namespace __MaterialUI {
focusState?: string; // 'none', 'focused', or 'keyboard-focused'
innerDivStyle?: React.CSSProperties;
insetChildren?: boolean;
label?: string | React.ReactNode;
leftIcon?: React.ReactElement<any>;
menuItems?: React.ReactNode;
onTouchTap?: TouchTapEventHandler;
@@ -1181,7 +1183,6 @@ declare namespace __MaterialUI {
rightIcon?: React.ReactElement<any>;
secondaryText?: React.ReactNode;
style?: React.CSSProperties;
value?: any;
containerElement?: React.ReactNode | string;
}
export class MenuItem extends React.Component<MenuItemProps> {
@@ -1264,6 +1265,8 @@ declare namespace __MaterialUI {
style?: React.CSSProperties;
transitionEnabled?: boolean;
zDepth?: number;
width?: number | string;
height?: number | string;
}
export class Paper extends React.Component<PaperProps> {
}
@@ -1413,7 +1416,8 @@ 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.InputHTMLAttributes<{}>, React.Props<T> {
label?: React.ReactNode;
}
interface EnhancedSwitchProps extends CommonEnhancedSwitchProps<EnhancedSwitch> {
@@ -1427,7 +1431,6 @@ declare namespace __MaterialUI {
id?: string;
inputStyle: React.CSSProperties;
inputType: string;
label?: string;
labelPosition?: string; // oneOf(['left', 'right'])
labelStyle?: React.CSSProperties;
name?: string;
+1 -1
View File
@@ -28,7 +28,7 @@ declare module "react-dropzone" {
disablePreview?: boolean; // Enable/disable preview generation
disableClick?: boolean; // Disallow clicking on the dropzone container to open file dialog
inputProps?: React.ChangeTargetHTMLProps<HTMLInputElement>; // Pass additional attributes to the <input type="file"/> tag
inputProps?: React.InputHTMLAttributes<HTMLInputElement>; // Pass additional attributes to the <input type="file"/> tag
multiple?: boolean; // Allow dropping multiple files
accept?: string; // Allow specific types of files. See https://github.com/okonet/attr-accept for more information
name?: string; // name attribute for the input tag
+1 -1
View File
@@ -7,7 +7,7 @@
import * as React from "react";
declare namespace reactInputMask {
interface ReactInputMaskProps extends React.HTMLAttributes<HTMLInputElement> {
interface ReactInputMaskProps extends React.InputHTMLAttributes<HTMLInputElement> {
/**
* Mask string. Format characters are:
* * `9`: `0-9`
+1 -1
View File
@@ -39,7 +39,7 @@ declare module 'react-router-dom' {
}
class HashRouter extends React.Component<HashRouterProps> {}
interface LinkProps extends React.HTMLAttributes<HTMLAnchorElement> {
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
to: H.LocationDescriptor;
replace?: boolean;
}
@@ -20,6 +20,7 @@ const CustomLinkExample = () => (
interface OldSchoolMenuLinkProps extends LinkProps {
activeOnlyWhenExact?: boolean;
label: string;
}
const OldSchoolMenuLink: React.SFC<OldSchoolMenuLinkProps> = ({ label, to, activeOnlyWhenExact }) => (
@@ -44,7 +44,7 @@ class TestApp extends React.Component<{}, State> {
]}
/>;
return <div id='test-app' classID='.MyClass'>
return <div id='test-app'>
{Tour}
</div>;
}
+731 -347
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -27,7 +27,7 @@ type InputType =
// Intermediate interface to "redefine" the type of size to string
// size:number => size:any => size:string
interface Intermediate extends React.ChangeTargetHTMLProps<HTMLInputElement> {
interface Intermediate extends React.InputHTMLAttributes<HTMLInputElement> {
size?: any;
}
+1 -1
View File
@@ -1,6 +1,6 @@
import { ColumnProps } from './Col';
interface Intermediate extends React.ChangeTargetHTMLProps<HTMLLabelElement> {
interface Intermediate extends React.LabelHTMLAttributes<HTMLLabelElement> {
size?: any;
}