Skip to content

Commit 7afc361

Browse files
authored
[react] Add types for part and exportparts props (DefinitelyTyped#72230)
1 parent 2d69cf2 commit 7afc361

File tree

13 files changed

+140
-0
lines changed

13 files changed

+140
-0
lines changed

types/react/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,14 @@ declare namespace React {
27522752
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
27532753
*/
27542754
is?: string | undefined;
2755+
/**
2756+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2757+
*/
2758+
exportparts?: string | undefined;
2759+
/**
2760+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2761+
*/
2762+
part?: string | undefined;
27552763
}
27562764

27572765
/**

types/react/test/elementAttributes.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import * as React from "react";
22

3+
declare module "react" {
4+
namespace JSX {
5+
interface IntrinsicElements {
6+
"custom-element": React.HTMLAttributes<unknown>;
7+
}
8+
}
9+
}
10+
311
const testCases = [
412
<span />,
513
<span accessKey="s" />,
@@ -157,6 +165,12 @@ const testCases = [
157165
Hide
158166
</button>
159167
</>,
168+
<>
169+
<template>
170+
<div part="base" />
171+
<custom-element exportparts="nested" />
172+
</template>
173+
</>,
160174
];
161175

162176
// Needed to check these HTML elements in event callbacks.

types/react/ts5.0/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,14 @@ declare namespace React {
27512751
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
27522752
*/
27532753
is?: string | undefined;
2754+
/**
2755+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2756+
*/
2757+
exportparts?: string | undefined;
2758+
/**
2759+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2760+
*/
2761+
part?: string | undefined;
27542762
}
27552763

27562764
/**

types/react/ts5.0/test/elementAttributes.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import * as React from "react";
22

3+
declare module "react" {
4+
namespace JSX {
5+
interface IntrinsicElements {
6+
"custom-element": React.HTMLAttributes<unknown>;
7+
}
8+
}
9+
}
10+
311
const testCases = [
412
<span />,
513
<span accessKey="s" />,
@@ -157,6 +165,12 @@ const testCases = [
157165
Hide
158166
</button>
159167
</>,
168+
<>
169+
<template>
170+
<div part="base" />
171+
<custom-element exportparts="nested" />
172+
</template>
173+
</>,
160174
];
161175

162176
// Needed to check these HTML elements in event callbacks.

types/react/v15/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,6 +2729,14 @@ declare namespace React {
27292729
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
27302730
*/
27312731
is?: string | undefined;
2732+
/**
2733+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2734+
*/
2735+
exportparts?: string | undefined;
2736+
/**
2737+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2738+
*/
2739+
part?: string | undefined;
27322740
}
27332741

27342742
interface AllHTMLAttributes<T> extends HTMLAttributes<T> {

types/react/v16/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,14 @@ declare namespace React {
19231923
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
19241924
*/
19251925
is?: string | undefined;
1926+
/**
1927+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
1928+
*/
1929+
exportparts?: string | undefined;
1930+
/**
1931+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
1932+
*/
1933+
part?: string | undefined;
19261934
}
19271935

19281936
interface AllHTMLAttributes<T> extends HTMLAttributes<T> {

types/react/v16/test/elementAttributes.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import * as React from "react";
22

3+
declare module "react" {
4+
namespace JSX {
5+
interface IntrinsicElements {
6+
"custom-element": React.HTMLAttributes<unknown>;
7+
}
8+
}
9+
}
10+
311
const testCases = [
412
<span />,
513
<span accessKey="s" />,
@@ -58,4 +66,10 @@ const testCases = [
5866
>
5967
</dialog>,
6068
<link nonce="8IBTHwOdqNKAWeKl7plt8g==" />,
69+
<>
70+
<template>
71+
<div part="base" />
72+
<custom-element exportparts="nested" />
73+
</template>
74+
</>,
6175
];

types/react/v17/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,14 @@ declare namespace React {
19241924
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
19251925
*/
19261926
is?: string | undefined;
1927+
/**
1928+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
1929+
*/
1930+
exportparts?: string | undefined;
1931+
/**
1932+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
1933+
*/
1934+
part?: string | undefined;
19271935
}
19281936

19291937
interface AllHTMLAttributes<T> extends HTMLAttributes<T> {

types/react/v17/test/elementAttributes.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import * as React from "react";
22

3+
declare module "react" {
4+
namespace JSX {
5+
interface IntrinsicElements {
6+
"custom-element": React.HTMLAttributes<unknown>;
7+
}
8+
}
9+
}
10+
311
const testCases = [
412
<span />,
513
<span accessKey="s" />,
@@ -73,6 +81,12 @@ const testCases = [
7381
>
7482
</dialog>,
7583
<link nonce="8IBTHwOdqNKAWeKl7plt8g==" />,
84+
<>
85+
<template>
86+
<div part="base" />
87+
<custom-element exportparts="nested" />
88+
</template>
89+
</>,
7690
];
7791

7892
// Needed to check these HTML elements in event callbacks.

types/react/v18/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,6 +2968,14 @@ declare namespace React {
29682968
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
29692969
*/
29702970
is?: string | undefined;
2971+
/**
2972+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2973+
*/
2974+
exportparts?: string | undefined;
2975+
/**
2976+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2977+
*/
2978+
part?: string | undefined;
29712979
}
29722980

29732981
/**

0 commit comments

Comments
 (0)