Skip to content

Commit

Permalink
support falsy values null & false
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed Mar 28, 2023
1 parent a001a20 commit 6263cfd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion packages/dts-test/tsx.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,34 @@ expectType<JSX.Element>(<div style={[{ color: 'red' }]} />)
expectType<JSX.Element>(
<div style={[{ color: 'red' }, [{ fontSize: '1em' }]]} />
)

// #7955
expectType<JSX.Element>(
<div style={[undefined, {background: 'green'}]} />
<div style={[undefined, '', null, false]} />
)

expectType<JSX.Element>(
<div style={undefined} />
)

expectType<JSX.Element>(
<div style={null} />
)

expectType<JSX.Element>(
<div style={''} />
)

expectType<JSX.Element>(
<div style={false} />
)

// @ts-expect-error
;<div style={[0]} />

// @ts-expect-error
;<div style={0} />

// @ts-expect-error unknown prop
;<div foo="bar" />

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/jsx-runtime/dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ interface AriaAttributes {
}

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

export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
innerHTML?: string
Expand Down

0 comments on commit 6263cfd

Please sign in to comment.