Skip to content

Commit 078ed0e

Browse files
authored
Updates dangerouslySetInnerHTML type so future TS will accept TrustedHTML automatically (#4930)
1 parent 5e18356 commit 078ed0e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
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-d.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { createElement, Fragment, SignalLike, UnpackSignal, AriaAttributes } from 'preact';
1+
import {
2+
createElement,
3+
Fragment,
4+
SignalLike,
5+
UnpackSignal,
6+
AriaAttributes
7+
} from 'preact';
28

39
function createSignal<T>(value: T): SignalLike<T> {
410
return {
@@ -249,3 +255,9 @@ const booleanishTest = (
249255
<div aria-haspopup={'dialog'} />
250256
</>
251257
);
258+
259+
const dangerouslySetInnerHTML = (
260+
<>
261+
<div dangerouslySetInnerHTML={{ __html: 'string' }} />
262+
</>
263+
);

0 commit comments

Comments
 (0)