@vue/language-core 3.0.0-beta.2 → 3.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/lib/codegen/codeFeatures.d.ts +5 -1
  2. package/lib/codegen/codeFeatures.js +3 -1
  3. package/lib/codegen/globalTypes.js +10 -9
  4. package/lib/codegen/localTypes.js +22 -8
  5. package/lib/codegen/script/component.js +2 -1
  6. package/lib/codegen/script/scriptSetup.js +53 -35
  7. package/lib/codegen/script/template.js +0 -1
  8. package/lib/codegen/style/classProperty.js +1 -1
  9. package/lib/codegen/style/imports.js +2 -2
  10. package/lib/codegen/style/scopedClasses.js +1 -1
  11. package/lib/codegen/template/context.d.ts +3 -2
  12. package/lib/codegen/template/context.js +4 -2
  13. package/lib/codegen/template/element.js +12 -12
  14. package/lib/codegen/template/elementDirectives.js +1 -1
  15. package/lib/codegen/template/elementEvents.js +9 -9
  16. package/lib/codegen/template/elementProps.js +4 -4
  17. package/lib/codegen/template/index.js +4 -4
  18. package/lib/codegen/template/interpolation.d.ts +3 -6
  19. package/lib/codegen/template/interpolation.js +11 -12
  20. package/lib/codegen/template/objectProperty.d.ts +1 -1
  21. package/lib/codegen/template/objectProperty.js +4 -4
  22. package/lib/codegen/template/propertyAccess.d.ts +1 -1
  23. package/lib/codegen/template/propertyAccess.js +2 -2
  24. package/lib/codegen/template/slotOutlet.js +4 -3
  25. package/lib/codegen/template/styleScopedClasses.js +4 -4
  26. package/lib/codegen/template/templateChild.js +3 -2
  27. package/lib/codegen/template/vFor.js +3 -3
  28. package/lib/codegen/template/vIf.js +1 -1
  29. package/lib/codegen/template/vSlot.js +2 -2
  30. package/lib/codegen/utils/escaped.d.ts +1 -1
  31. package/lib/codegen/utils/index.d.ts +1 -1
  32. package/lib/codegen/utils/index.js +7 -5
  33. package/lib/codegen/utils/wrapWith.d.ts +1 -1
  34. package/lib/languagePlugin.js +6 -3
  35. package/lib/parsers/scriptSetupRanges.js +14 -18
  36. package/lib/parsers/vueCompilerOptions.js +0 -1
  37. package/lib/plugins/file-html.js +6 -6
  38. package/lib/plugins/file-md.js +6 -5
  39. package/lib/plugins/file-vue.js +3 -4
  40. package/lib/plugins/vue-sfc-scripts.js +4 -2
  41. package/lib/plugins/vue-template-html.js +3 -4
  42. package/lib/plugins/vue-template-inline-ts.js +4 -2
  43. package/lib/plugins/vue-tsx.d.ts +2 -1
  44. package/lib/plugins/vue-tsx.js +2 -1
  45. package/lib/utils/parseCssImports.js +1 -1
  46. package/lib/utils/parseSfc.js +3 -3
  47. package/lib/utils/ts.js +9 -9
  48. package/lib/virtualFile/computedEmbeddedCodes.js +22 -11
  49. package/lib/virtualFile/computedSfc.d.ts +2 -0
  50. package/lib/virtualFile/computedSfc.js +114 -31
  51. package/package.json +4 -4
@@ -6,7 +6,6 @@ declare const raw: {
6
6
  semantic: true;
7
7
  navigation: true;
8
8
  };
9
- none: {};
10
9
  verification: {
11
10
  verification: true;
12
11
  };
@@ -50,6 +49,11 @@ declare const raw: {
50
49
  completion: true;
51
50
  semantic: true;
52
51
  };
52
+ semanticWithoutHighlight: {
53
+ semantic: {
54
+ shouldHighlight: () => false;
55
+ };
56
+ };
53
57
  withoutHighlight: {
54
58
  semantic: {
55
59
  shouldHighlight: () => false;
@@ -8,7 +8,6 @@ const raw = {
8
8
  semantic: true,
9
9
  navigation: true,
10
10
  },
11
- none: {},
12
11
  verification: {
13
12
  verification: true,
14
13
  },
@@ -46,6 +45,9 @@ const raw = {
46
45
  completion: true,
47
46
  semantic: true,
48
47
  },
48
+ semanticWithoutHighlight: {
49
+ semantic: { shouldHighlight: () => false },
50
+ },
49
51
  withoutHighlight: {
50
52
  semantic: { shouldHighlight: () => false },
51
53
  verification: true,
@@ -28,15 +28,15 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
28
28
  const __VLS_placeholder: any;
29
29
 
30
30
  type __VLS_NativeElements = __VLS_SpreadMerge<SVGElementTagNameMap, HTMLElementTagNameMap>;
31
- type __VLS_IntrinsicElements = ${(target >= 3.3
31
+ type __VLS_IntrinsicElements = ${target >= 3.3
32
32
  ? `import('${lib}/jsx-runtime').JSX.IntrinsicElements;`
33
- : `globalThis.JSX.IntrinsicElements;`)}
34
- type __VLS_Element = ${(target >= 3.3
33
+ : `globalThis.JSX.IntrinsicElements;`}
34
+ type __VLS_Element = ${target >= 3.3
35
35
  ? `import('${lib}/jsx-runtime').JSX.Element;`
36
- : `globalThis.JSX.Element;`)}
37
- type __VLS_GlobalComponents = ${(target >= 3.5
36
+ : `globalThis.JSX.Element;`}
37
+ type __VLS_GlobalComponents = ${target >= 3.5
38
38
  ? `import('${lib}').GlobalComponents;`
39
- : `import('${lib}').GlobalComponents & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`)}
39
+ : `import('${lib}').GlobalComponents & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`}
40
40
  type __VLS_GlobalDirectives = import('${lib}').GlobalDirectives;
41
41
  type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
42
42
  type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
@@ -117,13 +117,15 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
117
117
  type __VLS_ResolveEmits<
118
118
  Comp,
119
119
  Emits,
120
- TypeEmits = ${target >= 3.6 ? `Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('${lib}').ShortEmitsToObject<T> : {}` : `{}`},
120
+ TypeEmits = ${target >= 3.6
121
+ ? `Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('${lib}').ShortEmitsToObject<T> : {}`
122
+ : `{}`},
121
123
  NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
122
124
  > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
123
125
  type __VLS_ResolveDirectives<T> = {
124
126
  [K in Exclude<keyof T, keyof __VLS_GlobalDirectives> & string as \`v\${Capitalize<K>}\`]: T[K];
125
127
  };
126
- type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
128
+ type __VLS_PrettifyGlobal<T> = { [K in keyof T as K]: T[K]; } & {};
127
129
  type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
128
130
 
129
131
  function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
@@ -160,5 +162,4 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
160
162
  `;
161
163
  return text;
162
164
  }
163
- ;
164
165
  //# sourceMappingURL=globalTypes.js.map
@@ -16,7 +16,7 @@ type __VLS_WithDefaults<P, D> = {
16
16
  : P[K]
17
17
  };
18
18
  `.trimStart());
19
- const PrettifyLocal = defineHelper(`__VLS_PrettifyLocal`, () => `type __VLS_PrettifyLocal<T> = { [K in keyof T]: T[K]; } & {}${utils_1.endOfLine}`);
19
+ const PrettifyLocal = defineHelper(`__VLS_PrettifyLocal`, () => `type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K]; } & {}${utils_1.endOfLine}`);
20
20
  const WithSlots = defineHelper(`__VLS_WithSlots`, () => `
21
21
  type __VLS_WithSlots<T, S> = T & {
22
22
  new(): {
@@ -63,13 +63,27 @@ type __VLS_TypePropsToOption<T> = {
63
63
  getUsedNames() {
64
64
  return used;
65
65
  },
66
- get PrettifyLocal() { return PrettifyLocal.name; },
67
- get OmitKeepDiscriminatedUnion() { return OmitKeepDiscriminatedUnion.name; },
68
- get WithDefaults() { return WithDefaults.name; },
69
- get WithSlots() { return WithSlots.name; },
70
- get PropsChildren() { return PropsChildren.name; },
71
- get TypePropsToOption() { return TypePropsToOption.name; },
72
- get OmitIndexSignature() { return OmitIndexSignature.name; },
66
+ get PrettifyLocal() {
67
+ return PrettifyLocal.name;
68
+ },
69
+ get OmitKeepDiscriminatedUnion() {
70
+ return OmitKeepDiscriminatedUnion.name;
71
+ },
72
+ get WithDefaults() {
73
+ return WithDefaults.name;
74
+ },
75
+ get WithSlots() {
76
+ return WithSlots.name;
77
+ },
78
+ get PropsChildren() {
79
+ return PropsChildren.name;
80
+ },
81
+ get TypePropsToOption() {
82
+ return TypePropsToOption.name;
83
+ },
84
+ get OmitIndexSignature() {
85
+ return OmitIndexSignature.name;
86
+ },
73
87
  };
74
88
  function* generate(names) {
75
89
  const generated = new Set();
@@ -7,7 +7,8 @@ exports.generatePropsOption = generatePropsOption;
7
7
  const codeFeatures_1 = require("../codeFeatures");
8
8
  const utils_1 = require("../utils");
9
9
  function* generateComponent(options, ctx, scriptSetup, scriptSetupRanges) {
10
- if (options.sfc.script && options.scriptRanges?.exportDefault && options.scriptRanges.exportDefault.expression.start !== options.scriptRanges.exportDefault.args.start) {
10
+ if (options.sfc.script && options.scriptRanges?.exportDefault
11
+ && options.scriptRanges.exportDefault.expression.start !== options.scriptRanges.exportDefault.args.start) {
11
12
  // use defineComponent() from user space code if it exist
12
13
  yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, options.scriptRanges.exportDefault.expression.start, options.scriptRanges.exportDefault.args.start, codeFeatures_1.codeFeatures.all);
13
14
  yield `{${utils_1.newLine}`;
@@ -135,11 +135,11 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
135
135
  setupCodeModifies.push([
136
136
  [`(`],
137
137
  callExp.start,
138
- callExp.start
138
+ callExp.start,
139
139
  ], [
140
140
  [` as typeof __VLS_dollars.$attrs)`],
141
141
  callExp.end,
142
- callExp.end
142
+ callExp.end,
143
143
  ]);
144
144
  }
145
145
  }
@@ -147,25 +147,27 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
147
147
  setupCodeModifies.push([
148
148
  [`(`],
149
149
  callExp.start,
150
- callExp.start
150
+ callExp.start,
151
151
  ], [
152
- arg ? [
153
- ` as Omit<__VLS_StyleModules, '$style'>[`,
154
- (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.all),
155
- `])`
156
- ] : [
157
- ` as __VLS_StyleModules[`,
158
- ...(0, wrapWith_1.wrapWith)(exp.start, exp.end, scriptSetup.name, codeFeatures_1.codeFeatures.verification, `'$style'`),
159
- `])`
160
- ],
152
+ arg
153
+ ? [
154
+ ` as Omit<__VLS_StyleModules, '$style'>[`,
155
+ (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.all),
156
+ `])`,
157
+ ]
158
+ : [
159
+ ` as __VLS_StyleModules[`,
160
+ ...(0, wrapWith_1.wrapWith)(exp.start, exp.end, scriptSetup.name, codeFeatures_1.codeFeatures.verification, `'$style'`),
161
+ `])`,
162
+ ],
163
+ callExp.end,
161
164
  callExp.end,
162
- callExp.end
163
165
  ]);
164
166
  if (arg) {
165
167
  setupCodeModifies.push([
166
168
  [`__VLS_placeholder`],
167
169
  arg.start,
168
- arg.end
170
+ arg.end,
169
171
  ]);
170
172
  }
171
173
  }
@@ -174,11 +176,11 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
174
176
  setupCodeModifies.push([
175
177
  [`(`],
176
178
  callExp.start,
177
- callExp.start
179
+ callExp.start,
178
180
  ], [
179
181
  [` as typeof __VLS_dollars.$slots)`],
180
182
  callExp.end,
181
- callExp.end
183
+ callExp.end,
182
184
  ]);
183
185
  }
184
186
  }
@@ -188,7 +190,7 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
188
190
  ? [
189
191
  `__VLS_TemplateRefs[`,
190
192
  (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.withoutSemantic),
191
- `]`
193
+ `]`,
192
194
  ]
193
195
  : [`unknown`];
194
196
  if (isTs) {
@@ -196,32 +198,32 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
196
198
  [
197
199
  `<`,
198
200
  ...templateRefType,
199
- `>`
201
+ `>`,
200
202
  ],
201
203
  exp.end,
202
- exp.end
204
+ exp.end,
203
205
  ]);
204
206
  }
205
207
  else {
206
208
  setupCodeModifies.push([
207
209
  [`(`],
208
210
  callExp.start,
209
- callExp.start
211
+ callExp.start,
210
212
  ], [
211
213
  [
212
214
  ` as __VLS_UseTemplateRef<`,
213
215
  ...templateRefType,
214
- `>)`
216
+ `>)`,
215
217
  ],
216
218
  callExp.end,
217
- callExp.end
219
+ callExp.end,
218
220
  ]);
219
221
  }
220
222
  if (arg) {
221
223
  setupCodeModifies.push([
222
224
  [`__VLS_placeholder`],
223
225
  arg.start,
224
- arg.end
226
+ arg.end,
225
227
  ]);
226
228
  }
227
229
  }
@@ -277,11 +279,15 @@ function* generateMacros(options, ctx) {
277
279
  }
278
280
  function* generateDefineWithType(scriptSetup, statement, callExp, typeArg, name, defaultName, typeName) {
279
281
  if (typeArg) {
280
- yield [[
282
+ yield [
283
+ [
281
284
  `type ${typeName} = `,
282
285
  (0, utils_1.generateSfcBlockSection)(scriptSetup, typeArg.start, typeArg.end, codeFeatures_1.codeFeatures.all),
283
286
  utils_1.endOfLine,
284
- ], statement.start, statement.start];
287
+ ],
288
+ statement.start,
289
+ statement.start,
290
+ ];
285
291
  yield [[typeName], typeArg.start, typeArg.end];
286
292
  }
287
293
  if (!name) {
@@ -289,25 +295,37 @@ function* generateDefineWithType(scriptSetup, statement, callExp, typeArg, name,
289
295
  yield [[`const ${defaultName} = `], callExp.start, callExp.start];
290
296
  }
291
297
  else if (typeArg) {
292
- yield [[
298
+ yield [
299
+ [
293
300
  `const ${defaultName} = `,
294
- (0, utils_1.generateSfcBlockSection)(scriptSetup, callExp.start, typeArg.start, codeFeatures_1.codeFeatures.all)
295
- ], statement.start, typeArg.start];
296
- yield [[
301
+ (0, utils_1.generateSfcBlockSection)(scriptSetup, callExp.start, typeArg.start, codeFeatures_1.codeFeatures.all),
302
+ ],
303
+ statement.start,
304
+ typeArg.start,
305
+ ];
306
+ yield [
307
+ [
297
308
  (0, utils_1.generateSfcBlockSection)(scriptSetup, typeArg.end, callExp.end, codeFeatures_1.codeFeatures.all),
298
309
  utils_1.endOfLine,
299
310
  (0, utils_1.generateSfcBlockSection)(scriptSetup, statement.start, callExp.start, codeFeatures_1.codeFeatures.all),
300
- defaultName
301
- ], typeArg.end, callExp.end];
311
+ defaultName,
312
+ ],
313
+ typeArg.end,
314
+ callExp.end,
315
+ ];
302
316
  }
303
317
  else {
304
- yield [[
318
+ yield [
319
+ [
305
320
  `const ${defaultName} = `,
306
321
  (0, utils_1.generateSfcBlockSection)(scriptSetup, callExp.start, callExp.end, codeFeatures_1.codeFeatures.all),
307
322
  utils_1.endOfLine,
308
323
  (0, utils_1.generateSfcBlockSection)(scriptSetup, statement.start, callExp.start, codeFeatures_1.codeFeatures.all),
309
- defaultName
310
- ], statement.start, callExp.end];
324
+ defaultName,
325
+ ],
326
+ statement.start,
327
+ callExp.end,
328
+ ];
311
329
  }
312
330
  }
313
331
  }
@@ -415,7 +433,7 @@ function* generateDefineModelType(scriptSetup, propName, localName, defineModel)
415
433
  yield getRangeText(scriptSetup, defineModel.type);
416
434
  }
417
435
  else if (defineModel.runtimeType && localName) {
418
- // Infer from actual prop declaration code
436
+ // Infer from actual prop declaration code
419
437
  yield `typeof ${localName}['value']`;
420
438
  }
421
439
  else if (defineModel.defaultValue && propName) {
@@ -103,7 +103,6 @@ function* generateTemplateBody(options, templateCodegenCtx) {
103
103
  yield* options.templateCodegen.codes;
104
104
  }
105
105
  else {
106
- yield `// no template${utils_1.newLine}`;
107
106
  if (!options.scriptSetupRanges?.defineSlots) {
108
107
  yield `type __VLS_Slots = {}${utils_1.endOfLine}`;
109
108
  }
@@ -10,7 +10,7 @@ function* generateClassProperty(styleIndex, classNameWithDot, offset, propertyTy
10
10
  classNameWithDot.slice(1),
11
11
  'style_' + styleIndex,
12
12
  offset + 1,
13
- utils_1.combineLastMapping
13
+ utils_1.combineLastMapping,
14
14
  ], `'`);
15
15
  yield `: ${propertyType}`;
16
16
  yield ` }`;
@@ -6,7 +6,7 @@ const wrapWith_1 = require("../utils/wrapWith");
6
6
  function* generateStyleImports(style) {
7
7
  const features = {
8
8
  navigation: true,
9
- verification: true
9
+ verification: true,
10
10
  };
11
11
  if (typeof style.src === 'object') {
12
12
  yield `${utils_1.newLine} & typeof import(`;
@@ -19,7 +19,7 @@ function* generateStyleImports(style) {
19
19
  text,
20
20
  style.name,
21
21
  offset,
22
- features
22
+ features,
23
23
  ];
24
24
  yield `').default`;
25
25
  }
@@ -23,7 +23,7 @@ function* generateStyleScopedClasses(options, ctx) {
23
23
  ctx.scopedClasses.push({
24
24
  source: 'style_' + i,
25
25
  className: className.text.slice(1),
26
- offset: className.offset + 1
26
+ offset: className.offset + 1,
27
27
  });
28
28
  continue;
29
29
  }
@@ -100,7 +100,7 @@ export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenCont
100
100
  * an error/diagnostic was encountered for a region of code covered by a `@vue-expect-error` directive,
101
101
  * and additionally how we use that to determine whether to propagate diagnostics back upward.
102
102
  */
103
- export declare function createTemplateCodegenContext(options: Pick<TemplateCodegenOptions, 'scriptSetupBindingNames'>): {
103
+ export declare function createTemplateCodegenContext(options: Pick<TemplateCodegenOptions, 'scriptSetupBindingNames'>, templateAst?: CompilerDOM.RootNode): {
104
104
  readonly currentInfo: {
105
105
  ignoreError?: boolean;
106
106
  expectError?: {
@@ -114,7 +114,6 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
114
114
  };
115
115
  codeFeatures: {
116
116
  all: VueCodeInformation;
117
- none: VueCodeInformation;
118
117
  verification: VueCodeInformation;
119
118
  completion: VueCodeInformation;
120
119
  additionalCompletion: VueCodeInformation;
@@ -125,6 +124,7 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
125
124
  navigationAndAdditionalCompletion: VueCodeInformation;
126
125
  navigationAndVerification: VueCodeInformation;
127
126
  withoutNavigation: VueCodeInformation;
127
+ semanticWithoutHighlight: VueCodeInformation;
128
128
  withoutHighlight: VueCodeInformation;
129
129
  withoutHighlightAndNavigation: VueCodeInformation;
130
130
  withoutHighlightAndCompletion: VueCodeInformation;
@@ -132,6 +132,7 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
132
132
  withoutSemantic: VueCodeInformation;
133
133
  };
134
134
  resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation;
135
+ inlineTsAsts: Map<string, import("typescript").SourceFile> | undefined;
135
136
  inVFor: boolean;
136
137
  slots: {
137
138
  name: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTemplateCodegenContext = createTemplateCodegenContext;
4
4
  const CompilerDOM = require("@vue/compiler-dom");
5
+ const computedSfc_1 = require("../../virtualFile/computedSfc");
5
6
  const codeFeatures_1 = require("../codeFeatures");
6
7
  const utils_1 = require("../utils");
7
8
  const wrapWith_1 = require("../utils/wrapWith");
@@ -103,7 +104,7 @@ const commentDirectiveRegex = /^<!--\s*@vue-(?<name>[-\w]+)\b(?<content>[\s\S]*)
103
104
  * an error/diagnostic was encountered for a region of code covered by a `@vue-expect-error` directive,
104
105
  * and additionally how we use that to determine whether to propagate diagnostics back upward.
105
106
  */
106
- function createTemplateCodegenContext(options) {
107
+ function createTemplateCodegenContext(options, templateAst) {
107
108
  let variableId = 0;
108
109
  function resolveCodeFeatures(features) {
109
110
  if (features.verification && stack.length) {
@@ -160,6 +161,7 @@ function createTemplateCodegenContext(options) {
160
161
  },
161
162
  }),
162
163
  resolveCodeFeatures,
164
+ inlineTsAsts: templateAst && computedSfc_1.templateInlineTsAsts.get(templateAst),
163
165
  inVFor: false,
164
166
  slots,
165
167
  dynamicSlots,
@@ -243,7 +245,7 @@ function createTemplateCodegenContext(options) {
243
245
  offset,
244
246
  {
245
247
  ...codeFeatures_1.codeFeatures.additionalCompletion,
246
- ...codeFeatures_1.codeFeatures.withoutHighlightAndCompletionAndNavigation,
248
+ ...codeFeatures_1.codeFeatures.semanticWithoutHighlight,
247
249
  },
248
250
  ];
249
251
  }
@@ -55,7 +55,6 @@ function* generateComponent(options, ctx, node) {
55
55
  dynamicTagInfo = {
56
56
  tag: prop.exp.content,
57
57
  offsets: [prop.exp.loc.start.offset],
58
- astHolder: prop.exp.loc,
59
58
  };
60
59
  props = props.filter(p => p !== prop);
61
60
  break;
@@ -67,7 +66,6 @@ function* generateComponent(options, ctx, node) {
67
66
  dynamicTagInfo = {
68
67
  tag: node.tag,
69
68
  offsets: tagOffsets,
70
- astHolder: node.loc,
71
69
  };
72
70
  }
73
71
  if (matchImportName) {
@@ -93,10 +91,10 @@ function* generateComponent(options, ctx, node) {
93
91
  }
94
92
  else if (dynamicTagInfo) {
95
93
  yield `const ${componentOriginalVar} = (`;
96
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, dynamicTagInfo.tag, dynamicTagInfo.offsets[0], dynamicTagInfo.astHolder, `(`, `)`);
94
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, dynamicTagInfo.tag, dynamicTagInfo.offsets[0], `(`, `)`);
97
95
  if (dynamicTagInfo.offsets[1] !== undefined) {
98
96
  yield `,`;
99
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.withoutCompletion, dynamicTagInfo.tag, dynamicTagInfo.offsets[1], dynamicTagInfo.astHolder, `(`, `)`);
97
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.withoutCompletion, dynamicTagInfo.tag, dynamicTagInfo.offsets[1], `(`, `)`);
100
98
  }
101
99
  yield `)${utils_1.endOfLine}`;
102
100
  }
@@ -151,7 +149,7 @@ function* generateComponent(options, ctx, node) {
151
149
  // https://typescript.tv/errors/#ts6133
152
150
  return String(code) !== '6133';
153
151
  },
154
- }
152
+ },
155
153
  }), componentVNodeVar);
156
154
  yield ` = ${componentFunctionalVar}`;
157
155
  yield* generateComponentGeneric(ctx);
@@ -163,7 +161,8 @@ function* generateComponent(options, ctx, node) {
163
161
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
164
162
  const [refName, offset] = yield* generateElementReference(options, ctx, node);
165
163
  const tag = (0, shared_2.hyphenateTag)(node.tag);
166
- const isRootNode = ctx.singleRootNodes.has(node) && !options.vueCompilerOptions.fallthroughComponentNames.includes(tag);
164
+ const isRootNode = ctx.singleRootNodes.has(node)
165
+ && !options.vueCompilerOptions.fallthroughComponentNames.includes(tag);
167
166
  if (refName || isRootNode) {
168
167
  const componentInstanceVar = ctx.getInternalVariable();
169
168
  ctx.currentComponent.used = true;
@@ -192,7 +191,8 @@ function* generateComponent(options, ctx, node) {
192
191
  }
193
192
  }
194
193
  function* generateElement(options, ctx, node) {
195
- const startTagOffset = node.loc.start.offset + options.template.content.slice(node.loc.start.offset).indexOf(node.tag);
194
+ const startTagOffset = node.loc.start.offset
195
+ + options.template.content.slice(node.loc.start.offset).indexOf(node.tag);
196
196
  const endTagOffset = !node.isSelfClosing && options.template.lang === 'html'
197
197
  ? node.loc.start.offset + node.loc.source.lastIndexOf(node.tag)
198
198
  : undefined;
@@ -231,7 +231,7 @@ function* generateElement(options, ctx, node) {
231
231
  }
232
232
  function* generateFailedPropExps(options, ctx, failedPropExps) {
233
233
  for (const failedExp of failedPropExps) {
234
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, failedExp.node.loc.source, failedExp.node.loc.start.offset, failedExp.node.loc, failedExp.prefix, failedExp.suffix);
234
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, failedExp.node.loc.source, failedExp.node.loc.start.offset, failedExp.prefix, failedExp.suffix);
235
235
  yield utils_1.endOfLine;
236
236
  }
237
237
  }
@@ -268,7 +268,7 @@ function* generateComponentGeneric(ctx) {
268
268
  content,
269
269
  'template',
270
270
  offset,
271
- ctx.codeFeatures.all
271
+ ctx.codeFeatures.all,
272
272
  ], `>`);
273
273
  }
274
274
  }
@@ -280,7 +280,7 @@ function* generateElementReference(options, ctx, node) {
280
280
  const [content, startOffset] = (0, utils_1.normalizeAttributeValue)(prop.value);
281
281
  // navigation support for `const foo = ref()`
282
282
  yield `/** @type {typeof __VLS_ctx`;
283
- yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset, ctx.codeFeatures.navigation, prop.value.loc);
283
+ yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset, ctx.codeFeatures.navigation);
284
284
  yield `} */${utils_1.endOfLine}`;
285
285
  if (utils_1.identifierRegex.test(content) && !options.templateRefNames.has(content)) {
286
286
  ctx.accessExternalVariable(content, startOffset);
@@ -291,8 +291,8 @@ function* generateElementReference(options, ctx, node) {
291
291
  return [];
292
292
  }
293
293
  function hasVBindAttrs(options, ctx, node) {
294
- return options.vueCompilerOptions.fallthroughAttributes && ((options.inheritAttrs && ctx.singleRootNodes.has(node)) ||
295
- node.props.some(prop => prop.type === CompilerDOM.NodeTypes.DIRECTIVE
294
+ return options.vueCompilerOptions.fallthroughAttributes && ((options.inheritAttrs && ctx.singleRootNodes.has(node))
295
+ || node.props.some(prop => prop.type === CompilerDOM.NodeTypes.DIRECTIVE
296
296
  && prop.name === 'bind'
297
297
  && prop.exp?.loc.source === '$attrs'));
298
298
  }
@@ -53,7 +53,7 @@ function* generateArg(options, ctx, prop) {
53
53
  yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, ctx.codeFeatures.all);
54
54
  }
55
55
  else {
56
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, arg.content, startOffset, arg.loc, `(`, `)`);
56
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, arg.content, startOffset, `(`, `)`);
57
57
  }
58
58
  yield `, `;
59
59
  }
@@ -45,7 +45,7 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, compon
45
45
  const propName = (0, shared_1.camelize)(propPrefix + source);
46
46
  const emitName = emitPrefix + source;
47
47
  const camelizedEmitName = (0, shared_1.camelize)(emitName);
48
- yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> => (${utils_1.newLine}`;
48
+ yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${utils_1.newLine}`;
49
49
  if (prop.name === 'on') {
50
50
  yield `{ `;
51
51
  yield* generateEventArg(ctx, source, start, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation);
@@ -86,17 +86,17 @@ function* generateEventExpression(options, ctx, prop) {
86
86
  let prefix = `(`;
87
87
  let suffix = `)`;
88
88
  let isFirstMapping = true;
89
- const ast = (0, utils_1.createTsAst)(options.ts, prop.exp, prop.exp.content);
90
- const _isCompoundExpression = isCompoundExpression(options.ts, ast);
91
- if (_isCompoundExpression) {
92
- yield `(...[$event]) => {${utils_1.newLine}`;
89
+ const ast = (0, utils_1.createTsAst)(options.ts, ctx.inlineTsAsts, prop.exp.content);
90
+ const isCompound = isCompoundExpression(options.ts, ast);
91
+ if (isCompound) {
93
92
  ctx.addLocalVariable('$event');
93
+ yield `(...[$event]) => {${utils_1.newLine}`;
94
94
  yield* ctx.generateConditionGuards();
95
95
  prefix = ``;
96
96
  suffix = ``;
97
97
  }
98
98
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', offset => {
99
- if (_isCompoundExpression && isFirstMapping) {
99
+ if (isCompound && isFirstMapping) {
100
100
  isFirstMapping = false;
101
101
  ctx.inlayHints.push({
102
102
  blockName: 'template',
@@ -112,8 +112,8 @@ function* generateEventExpression(options, ctx, prop) {
112
112
  });
113
113
  }
114
114
  return ctx.codeFeatures.all;
115
- }, prop.exp.content, prop.exp.loc.start.offset, prop.exp.loc, prefix, suffix);
116
- if (_isCompoundExpression) {
115
+ }, prop.exp.content, prop.exp.loc.start.offset, prefix, suffix);
116
+ if (isCompound) {
117
117
  ctx.removeLocalVariable('$event');
118
118
  yield utils_1.endOfLine;
119
119
  yield* ctx.generateAutoImportCompletion();
@@ -128,7 +128,7 @@ function* generateModelEventExpression(options, ctx, prop) {
128
128
  if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
129
129
  yield `(...[$event]) => {${utils_1.newLine}`;
130
130
  yield* ctx.generateConditionGuards();
131
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.verification, prop.exp.content, prop.exp.loc.start.offset, prop.exp.loc);
131
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.verification, prop.exp.content, prop.exp.loc.start.offset);
132
132
  yield ` = $event${utils_1.endOfLine}`;
133
133
  yield `}`;
134
134
  }
@@ -82,7 +82,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
82
82
  yield `...{ `;
83
83
  }
84
84
  const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(prop.arg
85
- ? (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, codeInfo, prop.loc.name_2 ??= {}, shouldCamelize)
85
+ ? (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, codeInfo, shouldCamelize)
86
86
  : (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, ctx.codeFeatures.withoutHighlightAndCompletion, propName)), `: `, ...(0, wrapWith_1.wrapWith)(prop.arg?.loc.start.offset ?? prop.loc.start.offset, prop.arg?.loc.end.offset ?? prop.loc.end.offset, ctx.codeFeatures.verification, ...generatePropExp(options, ctx, prop, prop.exp, enableCodeFeatures)))];
87
87
  if (enableCodeFeatures) {
88
88
  yield* codes;
@@ -97,7 +97,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
97
97
  if (isComponent && prop.name === 'model' && prop.modifiers.length) {
98
98
  const propertyName = prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
99
99
  ? !prop.arg.isStatic
100
- ? `[__VLS_tryAsConstant(\`$\{${prop.arg.content}\}Modifiers\`)]`
100
+ ? `[__VLS_tryAsConstant(\`\${${prop.arg.content}}Modifiers\`)]`
101
101
  : (0, shared_1.camelize)(propName) + `Modifiers`
102
102
  : `modelModifiers`;
103
103
  const codes = [...(0, elementDirectives_1.generateModifiers)(options, ctx, prop, propertyName)];
@@ -120,7 +120,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
120
120
  if (shouldSpread) {
121
121
  yield `...{ `;
122
122
  }
123
- const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(0, objectProperty_1.generateObjectProperty)(options, ctx, prop.name, prop.loc.start.offset, codeInfo, prop.loc.name_1 ??= {}, shouldCamelize), `: `, ...(prop.value
123
+ const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(0, objectProperty_1.generateObjectProperty)(options, ctx, prop.name, prop.loc.start.offset, codeInfo, shouldCamelize), `: `, ...(prop.value
124
124
  ? generateAttrValue(prop.value, ctx.codeFeatures.withoutNavigation)
125
125
  : [`true`]))];
126
126
  if (enableCodeFeatures) {
@@ -163,7 +163,7 @@ function* generatePropExp(options, ctx, prop, exp, enableCodeFeatures = true) {
163
163
  : ctx.codeFeatures.all;
164
164
  if (exp && exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) { // style='z-index: 2' will compile to {'z-index':'2'}
165
165
  if (!isShorthand) { // vue 3.4+
166
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, exp.loc.source, exp.loc.start.offset, exp.loc, `(`, `)`);
166
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, exp.loc.source, exp.loc.start.offset, `(`, `)`);
167
167
  }
168
168
  else {
169
169
  const propVariableName = (0, shared_1.camelize)(exp.loc.source);