options.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import VNode from '../src/core/vdom/vnode'
  2. import { Component } from './component'
  3. declare type InternalComponentOptions = {
  4. _isComponent: true
  5. parent: Component
  6. _parentVnode: VNode
  7. render?: Function
  8. staticRenderFns?: Array<Function>
  9. }
  10. type InjectKey = string | Symbol
  11. declare interface SetupContext {
  12. attrs: Record<string, any>
  13. slots: Record<string, () => VNode[]>
  14. emit: (event: string, ...args: any[]) => any
  15. }
  16. declare type ComponentOptions = {
  17. // v3
  18. setup?: (props: Record<string, any>, ctx: SetupContext) => unknown
  19. [key: string]: any
  20. componentId?: string
  21. // data
  22. data: object | Function | void
  23. props?: { [key: string]: PropOptions }
  24. propsData?: object
  25. computed?: {
  26. [key: string]:
  27. | Function
  28. | {
  29. get?: Function
  30. set?: Function
  31. cache?: boolean
  32. }
  33. }
  34. methods?: { [key: string]: Function }
  35. watch?: { [key: string]: Function | string }
  36. // DOM
  37. el?: string | Element
  38. template?: string
  39. render: (h: () => VNode) => VNode
  40. renderError?: (h: () => VNode, err: Error) => VNode
  41. staticRenderFns?: Array<() => VNode>
  42. // lifecycle
  43. beforeCreate?: Function
  44. created?: Function
  45. beforeMount?: Function
  46. mounted?: Function
  47. beforeUpdate?: Function
  48. updated?: Function
  49. activated?: Function
  50. deactivated?: Function
  51. beforeDestroy?: Function
  52. destroyed?: Function
  53. errorCaptured?: () => boolean | void
  54. serverPrefetch?: Function
  55. // assets
  56. directives?: { [key: string]: object }
  57. components?: { [key: string]: Component }
  58. transitions?: { [key: string]: object }
  59. filters?: { [key: string]: Function }
  60. // context
  61. provide?: Record<string | symbol, any> | (() => Record<string | symbol, any>)
  62. inject?:
  63. | { [key: string]: InjectKey | { from?: InjectKey; default?: any } }
  64. | Array<string>
  65. // component v-model customization
  66. model?: {
  67. prop?: string
  68. event?: string
  69. }
  70. // misc
  71. parent?: Component
  72. mixins?: Array<object>
  73. name?: string
  74. extends?: Component | object
  75. delimiters?: [string, string]
  76. comments?: boolean
  77. inheritAttrs?: boolean
  78. // Class API
  79. abstract?: any
  80. // private
  81. _isComponent?: true
  82. _propKeys?: Array<string>
  83. _parentVnode?: VNode
  84. _parentListeners?: object | null
  85. _renderChildren?: Array<VNode> | null
  86. _componentTag: string | null
  87. _scopeId: string | null
  88. _base: typeof Component
  89. }
  90. declare type PropOptions = {
  91. type: Function | Array<Function> | null
  92. default: any
  93. required: boolean | null
  94. validator: Function | null
  95. }