Skip to content

Commit 3ab5c6f

Browse files
Updates dangerouslySetInnerHTML type so future TS will accept Trusted… (#4931)
* Updates dangerouslySetInnerHTML type so future TS will accept TrustedHTML automatically * test: Add simple type test --------- Co-authored-by: Ryan Christian <[email protected]>
1 parent ff30c2b commit 3ab5c6f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface ClassAttributes<T> extends Attributes {
6666
export interface PreactDOMAttributes {
6767
children?: ComponentChildren;
6868
dangerouslySetInnerHTML?: {
69-
__html: string;
69+
__html: Parameters<DOMParser['parseFromString']>[0];
7070
};
7171
}
7272

test/ts/dom-attributes-test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ const booleanishTest = (
4949
<div aria-haspopup={'dialog'} />
5050
</>
5151
);
52+
53+
const dangerouslySetInnerHTML = (
54+
<>
55+
<div dangerouslySetInnerHTML={{ __html: 'string' }} />
56+
</>
57+
);

0 commit comments

Comments
 (0)