Преглед на файлове

refactor: extract SFCInternalOptions inteface

Evan You преди 6 години
родител
ревизия
b2c2d0590e
променени са 2 файла, в които са добавени 10 реда и са изтрити 12 реда
  1. 3 7
      packages/runtime-core/src/apiOptions.ts
  2. 7 5
      packages/runtime-core/src/component.ts

+ 3 - 7
packages/runtime-core/src/apiOptions.ts

@@ -3,7 +3,8 @@ import {
   Data,
   Component,
   SetupContext,
-  RenderFunction
+  RenderFunction,
+  SFCInternalOptions
 } from './component'
 import {
   isFunction,
@@ -48,7 +49,7 @@ export interface ComponentOptionsBase<
   D,
   C extends ComputedOptions,
   M extends MethodOptions
-> extends LegacyOptions<Props, RawBindings, D, C, M> {
+> extends LegacyOptions<Props, RawBindings, D, C, M>, SFCInternalOptions {
   setup?: (
     this: null,
     props: Props,
@@ -66,11 +67,6 @@ export interface ComponentOptionsBase<
   directives?: Record<string, Directive>
   inheritAttrs?: boolean
 
-  // SFC & dev only
-  __scopeId?: string
-  __hmrId?: string
-  __hmrUpdated?: boolean
-
   // type-only differentiator to separate OptionWithoutProps from a constructor
   // type returned by createComponent() or FunctionalComponent
   call?: never

+ 7 - 5
packages/runtime-core/src/component.ts

@@ -32,15 +32,17 @@ import { currentRenderingInstance } from './componentRenderUtils'
 
 export type Data = { [key: string]: unknown }
 
-export interface FunctionalComponent<P = {}> {
+export interface SFCInternalOptions {
+  __scopeId?: string
+  __hmrId?: string
+  __hmrUpdated?: boolean
+}
+
+export interface FunctionalComponent<P = {}> extends SFCInternalOptions {
   (props: P, ctx: SetupContext): VNodeChild
   props?: ComponentPropsOptions<P>
   inheritAttrs?: boolean
   displayName?: string
-
-  // internal HMR related flags
-  __hmrId?: string
-  __hmrUpdated?: boolean
 }
 
 export type Component = ComponentOptions | FunctionalComponent