ソースを参照

types(jsx): flexible class attribute declarations (#14441)

close: vuejs/rfcs#820
Zachary Bear 2 ヶ月 前
コミット
521157d0c3
1 ファイル変更11 行追加2 行削除
  1. 11 2
      packages/runtime-dom/src/jsx.ts

+ 11 - 2
packages/runtime-dom/src/jsx.ts

@@ -275,10 +275,19 @@ export type StyleValue =
   | CSSProperties
   | CSSProperties
   | Array<StyleValue>
   | Array<StyleValue>
 
 
+// Support for `class` attribute
+export type ClassValue =
+  | false
+  | null
+  | undefined
+  | string
+  | Record<string, any>
+  | Array<ClassValue>
+
 export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
 export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
   innerHTML?: string | undefined
   innerHTML?: string | undefined
 
 
-  class?: any
+  class?: ClassValue | undefined
   style?: StyleValue | undefined
   style?: StyleValue | undefined
 
 
   // Standard HTML Attributes
   // Standard HTML Attributes
@@ -916,7 +925,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers<Events> {
    * SVG Styling Attributes
    * SVG Styling Attributes
    * @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling
    * @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling
    */
    */
-  class?: any
+  class?: ClassValue | undefined
   style?: StyleValue | undefined
   style?: StyleValue | undefined
 
 
   color?: string | undefined
   color?: string | undefined