Skip to content

Commit 32029fc

Browse files
committed
Merge pull request DefinitelyTyped#5915 from ngbrown/patch-7
react.d.ts: Make a generic base version of HTMLAttributes and DOMAttributes
2 parents 51268e1 + 7d0beb4 commit 32029fc

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

react/react.d.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ declare namespace __React {
336336
ref?: string | ((component: T) => any);
337337
}
338338

339-
interface DOMAttributes extends Props<DOMComponent<any>> {
339+
interface DOMAttributesBase<T> extends Props<T> {
340340
onCopy?: ClipboardEventHandler;
341341
onCut?: ClipboardEventHandler;
342342
onPaste?: ClipboardEventHandler;
@@ -377,6 +377,9 @@ declare namespace __React {
377377
};
378378
}
379379

380+
interface DOMAttributes extends DOMAttributesBase<DOMComponent<any>> {
381+
}
382+
380383
// This interface is not complete. Only properties accepting
381384
// unitless numbers are listed here (see CSSProperty.js in React)
382385
interface CSSProperties {
@@ -406,9 +409,7 @@ declare namespace __React {
406409
[propertyName: string]: any;
407410
}
408411

409-
interface HTMLAttributes extends DOMAttributes {
410-
ref?: string | ((component: HTMLComponent) => void);
411-
412+
interface HTMLAttributesBase<T> extends DOMAttributesBase<T> {
412413
accept?: string;
413414
acceptCharset?: string;
414415
accessKey?: string;
@@ -528,6 +529,9 @@ declare namespace __React {
528529
unselectable?: boolean;
529530
}
530531

532+
interface HTMLAttributes extends HTMLAttributesBase<HTMLComponent> {
533+
}
534+
531535
interface SVGElementAttributes extends HTMLAttributes {
532536
viewBox?: string;
533537
preserveAspectRatio?: string;
@@ -1133,7 +1137,7 @@ declare module "react/addons" {
11331137
ref?: string | ((component: T) => any);
11341138
}
11351139

1136-
interface DOMAttributes extends Props<DOMComponent<any>> {
1140+
interface DOMAttributesBase<T> extends Props<T> {
11371141
onCopy?: ClipboardEventHandler;
11381142
onCut?: ClipboardEventHandler;
11391143
onPaste?: ClipboardEventHandler;
@@ -1174,6 +1178,9 @@ declare module "react/addons" {
11741178
};
11751179
}
11761180

1181+
interface DOMAttributes extends DOMAttributesBase<DOMComponent<any>> {
1182+
}
1183+
11771184
// This interface is not complete. Only properties accepting
11781185
// unitless numbers are listed here (see CSSProperty.js in React)
11791186
interface CSSProperties {
@@ -1203,9 +1210,7 @@ declare module "react/addons" {
12031210
[propertyName: string]: any;
12041211
}
12051212

1206-
interface HTMLAttributes extends DOMAttributes {
1207-
ref?: string | ((component: HTMLComponent) => void);
1208-
1213+
interface HTMLAttributesBase<T> extends DOMAttributesBase<T> {
12091214
accept?: string;
12101215
acceptCharset?: string;
12111216
accessKey?: string;
@@ -1325,6 +1330,9 @@ declare module "react/addons" {
13251330
unselectable?: boolean;
13261331
}
13271332

1333+
interface HTMLAttributes extends HTMLAttributesBase<HTMLComponent> {
1334+
}
1335+
13281336
interface SVGElementAttributes extends HTMLAttributes {
13291337
viewBox?: string;
13301338
preserveAspectRatio?: string;

0 commit comments

Comments
 (0)