From 17aa92b79b31d8bb8b5873ddc599420cb9806db8 Mon Sep 17 00:00:00 2001 From: Yuchao Date: Fri, 10 Nov 2023 17:23:54 +1100 Subject: [PATCH] fix(types): allow falsy value types in `StyleValue` (#7954) close #7955 --- packages/dts-test/tsx.test-d.tsx | 27 +++++++++++++++++++++++++++ packages/runtime-dom/src/jsx.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/dts-test/tsx.test-d.tsx b/packages/dts-test/tsx.test-d.tsx index 04915a9673f..47555a03c0b 100644 --- a/packages/dts-test/tsx.test-d.tsx +++ b/packages/dts-test/tsx.test-d.tsx @@ -17,6 +17,33 @@ expectType(
) +// #7955 +expectType( +
+) + +expectType( +
+) + +expectType( +
+) + +expectType( +
+) + +expectType( +
+) + +// @ts-expect-error +;
+ +// @ts-expect-error +;
+ // @ts-expect-error unknown prop ;
diff --git a/packages/runtime-dom/src/jsx.ts b/packages/runtime-dom/src/jsx.ts index 7769418653e..3ab2de8b772 100644 --- a/packages/runtime-dom/src/jsx.ts +++ b/packages/runtime-dom/src/jsx.ts @@ -244,7 +244,7 @@ interface AriaAttributes { } // Vue's style normalization supports nested arrays -export type StyleValue = string | CSSProperties | Array +export type StyleValue = false | null | undefined | string | CSSProperties | Array export interface HTMLAttributes extends AriaAttributes, EventHandlers { innerHTML?: string