]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(types): move component props interfaces + expose `AllowedComponentProps`
authorEvan You <yyx990803@gmail.com>
Sun, 19 Jul 2020 18:09:37 +0000 (14:09 -0400)
committerEvan You <yyx990803@gmail.com>
Sun, 19 Jul 2020 18:09:53 +0000 (14:09 -0400)
fix #1632

packages/runtime-core/src/apiDefineComponent.ts
packages/runtime-core/src/component.ts
packages/runtime-core/src/index.ts
packages/runtime-core/src/vnode.ts

index ea53f96ad1190a3c755e02286d184db79a8b1bf5..1a22c50ff10dc4bee965321338d51690f0cf6ec8 100644 (file)
@@ -7,7 +7,12 @@ import {
   ComponentOptionsMixin,
   RenderFunction
 } from './componentOptions'
-import { SetupContext, FunctionalComponent } from './component'
+import {
+  SetupContext,
+  FunctionalComponent,
+  AllowedComponentProps,
+  ComponentCustomProps
+} from './component'
 import {
   CreateComponentPublicInstance,
   ComponentPublicInstanceConstructor
@@ -15,11 +20,7 @@ import {
 import { ExtractPropTypes, ComponentPropsOptions } from './componentProps'
 import { EmitsOptions } from './componentEmits'
 import { isFunction } from '@vue/shared'
-import {
-  VNodeProps,
-  AllowedComponentProps,
-  ComponentCustomProps
-} from './vnode'
+import { VNodeProps } from './vnode'
 
 // defineComponent is a utility that is primarily used for type inference
 // when declaring components. Type inference is provided in the component
index 621d8ae6b472ef4521d474f3ee2a6dd718e379cc..f34031d713bfcea4d228b0023ebac641eeebabdf 100644 (file)
@@ -53,6 +53,19 @@ import { componentAdded } from './devtools'
 
 export type Data = Record<string, unknown>
 
+/**
+ * For extending allowed non-declared props on components in TSX
+ */
+export interface ComponentCustomProps {}
+
+/**
+ * Default allowed non-declared props on ocmponent in TSX
+ */
+export interface AllowedComponentProps {
+  class?: unknown
+  style?: unknown
+}
+
 // Note: can't mark this whole interface internal because some public interfaces
 // extend it.
 export interface ComponentInternalOptions {
index 39de3cca2a3776ff565290a1cc30bbb1c9bb155a..757a21382bcaea9c0a23542113e0e8926f79f343 100644 (file)
@@ -54,7 +54,7 @@ export { h } from './h'
 // Advanced render function utilities
 export { createVNode, cloneVNode, mergeProps, isVNode } from './vnode'
 // VNode types
-export { Fragment, Text, Comment, Static, ComponentCustomProps } from './vnode'
+export { Fragment, Text, Comment, Static } from './vnode'
 // Built-in components
 export { Teleport, TeleportProps } from './components/Teleport'
 export { Suspense, SuspenseProps } from './components/Suspense'
@@ -159,7 +159,9 @@ export {
   Component,
   FunctionalComponent,
   ComponentInternalInstance,
-  SetupContext
+  SetupContext,
+  ComponentCustomProps,
+  AllowedComponentProps
 } from './component'
 export {
   ComponentOptions,
index f477933ab8362891a2d0da615732799ee9767694..5cde39f87ebc9257dac11e1722b7677781797a63 100644 (file)
@@ -71,12 +71,6 @@ export type VNodeHook =
   | VNodeMountHook[]
   | VNodeUpdateHook[]
 
-export interface ComponentCustomProps {}
-export interface AllowedComponentProps {
-  class?: unknown
-  style?: unknown
-}
-
 // https://github.com/microsoft/TypeScript/issues/33099
 export type VNodeProps = {
   key?: string | number