Skip to content

Commit 6263cfd

Browse files
committed
support falsy values null & false
1 parent a001a20 commit 6263cfd

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,34 @@ expectType<JSX.Element>(<div style={[{ color: 'red' }]} />)
1515
expectType<JSX.Element>(
1616
<div style={[{ color: 'red' }, [{ fontSize: '1em' }]]} />
1717
)
18+
19+
// #7955
1820
expectType<JSX.Element>(
19-
<div style={[undefined, {background: 'green'}]} />
21+
<div style={[undefined, '', null, false]} />
2022
)
2123

24+
expectType<JSX.Element>(
25+
<div style={undefined} />
26+
)
27+
28+
expectType<JSX.Element>(
29+
<div style={null} />
30+
)
31+
32+
expectType<JSX.Element>(
33+
<div style={''} />
34+
)
35+
36+
expectType<JSX.Element>(
37+
<div style={false} />
38+
)
39+
40+
// @ts-expect-error
41+
;<div style={[0]} />
42+
43+
// @ts-expect-error
44+
;<div style={0} />
45+
2246
// @ts-expect-error unknown prop
2347
;<div foo="bar" />
2448

packages/vue/jsx-runtime/dom.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ interface AriaAttributes {
234234
}
235235

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

239239
export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
240240
innerHTML?: string

0 commit comments

Comments
 (0)