|
1 | 1 | /**
|
2 |
| - * This declaration is copied from https://github.com/vuejs/vue/pull/7918 |
3 |
| - * which may included vue-template-compiler v2.6.0. |
| 2 | + * augment the original types with the needed comments |
4 | 3 | */
|
| 4 | +import 'vue-template-compiler' |
5 | 5 |
|
6 | 6 | declare module 'vue-template-compiler' {
|
7 |
| - import Vue, { VNode } from 'vue' |
8 |
| - |
9 |
| - /* |
10 |
| - * Template compilation options / results |
11 |
| - */ |
12 | 7 | interface CompilerOptions {
|
13 |
| - modules?: ModuleOptions[] |
14 |
| - directives?: Record<string, DirectiveFunction> |
15 |
| - preserveWhitespace?: boolean |
16 | 8 | comments?: boolean
|
17 | 9 | }
|
18 |
| - |
19 |
| - interface CompiledResult { |
20 |
| - ast: ASTElement | undefined |
21 |
| - render: string |
22 |
| - staticRenderFns: string[] |
23 |
| - errors: string[] |
24 |
| - tips: string[] |
25 |
| - } |
26 |
| - |
27 |
| - interface CompiledResultFunctions { |
28 |
| - render: () => VNode |
29 |
| - staticRenderFns: (() => VNode)[] |
30 |
| - } |
31 |
| - |
32 |
| - interface ModuleOptions { |
33 |
| - preTransformNode: (el: ASTElement) => ASTElement | undefined |
34 |
| - transformNode: (el: ASTElement) => ASTElement | undefined |
35 |
| - postTransformNode: (el: ASTElement) => void |
36 |
| - genData: (el: ASTElement) => string |
37 |
| - transformCode?: (el: ASTElement, code: string) => string |
38 |
| - staticKeys?: string[] |
39 |
| - } |
40 |
| - |
41 |
| - type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void |
42 |
| - |
43 |
| - /* |
44 |
| - * AST Types |
45 |
| - */ |
46 |
| - |
47 |
| - /** |
48 |
| - * - 0: FALSE - whole sub tree un-optimizable |
49 |
| - * - 1: FULL - whole sub tree optimizable |
50 |
| - * - 2: SELF - self optimizable but has some un-optimizable children |
51 |
| - * - 3: CHILDREN - self un-optimizable but have fully optimizable children |
52 |
| - * - 4: PARTIAL - self un-optimizable with some un-optimizable children |
53 |
| - */ |
54 |
| - export type SSROptimizability = 0 | 1 | 2 | 3 | 4 |
55 |
| - |
56 |
| - export interface ASTModifiers { |
57 |
| - [key: string]: boolean |
58 |
| - } |
59 |
| - |
60 |
| - export interface ASTIfCondition { |
61 |
| - exp: string | undefined |
62 |
| - block: ASTElement |
63 |
| - } |
64 |
| - |
65 |
| - export interface ASTElementHandler { |
66 |
| - value: string |
67 |
| - params?: any[] |
68 |
| - modifiers: ASTModifiers | undefined |
69 |
| - } |
70 |
| - |
71 |
| - export interface ASTElementHandlers { |
72 |
| - [key: string]: ASTElementHandler | ASTElementHandler[] |
73 |
| - } |
74 |
| - |
75 |
| - export interface ASTDirective { |
76 |
| - name: string |
77 |
| - rawName: string |
78 |
| - value: string |
79 |
| - arg: string | undefined |
80 |
| - modifiers: ASTModifiers | undefined |
81 |
| - } |
82 |
| - |
83 |
| - export type ASTNode = ASTElement | ASTText | ASTExpression |
84 |
| - |
85 |
| - export interface ASTElement { |
86 |
| - type: 1 |
87 |
| - tag: string |
88 |
| - attrsList: { name: string; value: any }[] |
89 |
| - attrsMap: Record<string, any> |
90 |
| - parent: ASTElement | undefined |
91 |
| - children: ASTNode[] |
92 |
| - |
93 |
| - processed?: true |
94 |
| - |
95 |
| - static?: boolean |
96 |
| - staticRoot?: boolean |
97 |
| - staticInFor?: boolean |
98 |
| - staticProcessed?: boolean |
99 |
| - hasBindings?: boolean |
100 |
| - |
101 |
| - text?: string |
102 |
| - attrs?: { name: string; value: any }[] |
103 |
| - props?: { name: string; value: string }[] |
104 |
| - plain?: boolean |
105 |
| - pre?: true |
106 |
| - ns?: string |
107 |
| - |
108 |
| - component?: string |
109 |
| - inlineTemplate?: true |
110 |
| - transitionMode?: string | null |
111 |
| - slotName?: string |
112 |
| - slotTarget?: string |
113 |
| - slotScope?: string |
114 |
| - scopedSlots?: Record<string, ASTElement> |
115 |
| - |
116 |
| - ref?: string |
117 |
| - refInFor?: boolean |
118 |
| - |
119 |
| - if?: string |
120 |
| - ifProcessed?: boolean |
121 |
| - elseif?: string |
122 |
| - else?: true |
123 |
| - ifConditions?: ASTIfCondition[] |
124 |
| - |
125 |
| - for?: string |
126 |
| - forProcessed?: boolean |
127 |
| - key?: string |
128 |
| - alias?: string |
129 |
| - iterator1?: string |
130 |
| - iterator2?: string |
131 |
| - |
132 |
| - staticClass?: string |
133 |
| - classBinding?: string |
134 |
| - staticStyle?: string |
135 |
| - styleBinding?: string |
136 |
| - events?: ASTElementHandlers |
137 |
| - nativeEvents?: ASTElementHandlers |
138 |
| - |
139 |
| - transition?: string | true |
140 |
| - transitionOnAppear?: boolean |
141 |
| - |
142 |
| - model?: { |
143 |
| - value: string |
144 |
| - callback: string |
145 |
| - expression: string |
146 |
| - } |
147 |
| - |
148 |
| - directives?: ASTDirective[] |
149 |
| - |
150 |
| - forbidden?: true |
151 |
| - once?: true |
152 |
| - onceProcessed?: boolean |
153 |
| - wrapData?: (code: string) => string |
154 |
| - wrapListeners?: (code: string) => string |
155 |
| - |
156 |
| - // 2.4 ssr optimization |
157 |
| - ssrOptimizability?: SSROptimizability |
158 |
| - |
159 |
| - // weex specific |
160 |
| - appendAsTree?: boolean |
161 |
| - } |
162 |
| - |
163 |
| - export interface ASTExpression { |
164 |
| - type: 2 |
165 |
| - expression: string |
166 |
| - text: string |
167 |
| - tokens: (string | Record<string, any>)[] |
168 |
| - static?: boolean |
169 |
| - // 2.4 ssr optimization |
170 |
| - ssrOptimizability?: SSROptimizability |
171 |
| - } |
172 |
| - |
173 |
| - export interface ASTText { |
174 |
| - type: 3 |
175 |
| - text: string |
176 |
| - static?: boolean |
177 |
| - isComment?: boolean |
178 |
| - // 2.4 ssr optimization |
179 |
| - ssrOptimizability?: SSROptimizability |
180 |
| - } |
181 |
| - |
182 |
| - /* |
183 |
| - * SFC parser related types |
184 |
| - */ |
185 |
| - interface SFCParserOptions { |
186 |
| - pad?: true | 'line' | 'space' |
187 |
| - } |
188 |
| - |
189 |
| - export interface SFCBlock { |
190 |
| - type: string |
191 |
| - content: string |
192 |
| - attrs: Record<string, string> |
193 |
| - start?: number |
194 |
| - end?: number |
195 |
| - lang?: string |
196 |
| - src?: string |
197 |
| - scoped?: boolean |
198 |
| - module?: string | boolean |
199 |
| - } |
200 |
| - |
201 |
| - export interface SFCDescriptor { |
202 |
| - template: SFCBlock | undefined |
203 |
| - script: SFCBlock | undefined |
204 |
| - styles: SFCBlock[] |
205 |
| - customBlocks: SFCBlock[] |
206 |
| - } |
207 |
| - |
208 |
| - /* |
209 |
| - * Exposed functions |
210 |
| - */ |
211 |
| - export function compile(template: string, options?: CompilerOptions): CompiledResult |
212 |
| - |
213 |
| - export function compileToFunctions(template: string): CompiledResultFunctions |
214 |
| - |
215 |
| - export function ssrCompile(template: string, options?: CompilerOptions): CompiledResult |
216 |
| - |
217 |
| - export function ssrCompileToFunctions(template: string): CompiledResultFunctions |
218 |
| - |
219 |
| - export function parseComponent(file: string, options?: SFCParserOptions): SFCDescriptor |
220 | 10 | }
|
0 commit comments