Skip to content

Commit 17aa92b

Browse files
authoredNov 10, 2023
fix(types): allow falsy value types in StyleValue (#7954)
close #7955
1 parent d5fd343 commit 17aa92b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 

‎packages/dts-test/tsx.test-d.tsx

+27
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@ expectType<JSX.Element>(
1717
<div style={[{ color: 'red' }, [{ fontSize: '1em' }]]} />
1818
)
1919

20+
// #7955
21+
expectType<JSX.Element>(
22+
<div style={[undefined, '', null, false]} />
23+
)
24+
25+
expectType<JSX.Element>(
26+
<div style={undefined} />
27+
)
28+
29+
expectType<JSX.Element>(
30+
<div style={null} />
31+
)
32+
33+
expectType<JSX.Element>(
34+
<div style={''} />
35+
)
36+
37+
expectType<JSX.Element>(
38+
<div style={false} />
39+
)
40+
41+
// @ts-expect-error
42+
;<div style={[0]} />
43+
44+
// @ts-expect-error
45+
;<div style={0} />
46+
2047
// @ts-expect-error unknown prop
2148
;<div foo="bar" />
2249

‎packages/runtime-dom/src/jsx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ interface AriaAttributes {
244244
}
245245

246246
// Vue's style normalization supports nested arrays
247-
export type StyleValue = string | CSSProperties | Array<StyleValue>
247+
export type StyleValue = false | null | undefined | string | CSSProperties | Array<StyleValue>
248248

249249
export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
250250
innerHTML?: string

0 commit comments

Comments
 (0)
Please sign in to comment.