@vue/language-core 3.0.3 → 3.0.5

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 (47) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -1
  3. package/lib/codegen/codeFeatures.d.ts +20 -17
  4. package/lib/codegen/codeFeatures.js +23 -13
  5. package/lib/codegen/globalTypes.d.ts +2 -2
  6. package/lib/codegen/globalTypes.js +27 -24
  7. package/lib/codegen/script/context.d.ts +0 -6
  8. package/lib/codegen/script/index.d.ts +2 -1
  9. package/lib/codegen/script/index.js +16 -4
  10. package/lib/codegen/script/scriptSetup.js +4 -5
  11. package/lib/codegen/template/context.d.ts +0 -19
  12. package/lib/codegen/template/context.js +0 -6
  13. package/lib/codegen/template/element.js +23 -21
  14. package/lib/codegen/template/elementDirectives.js +10 -10
  15. package/lib/codegen/template/elementEvents.d.ts +1 -1
  16. package/lib/codegen/template/elementEvents.js +23 -20
  17. package/lib/codegen/template/elementProps.js +17 -24
  18. package/lib/codegen/template/index.d.ts +3 -2
  19. package/lib/codegen/template/index.js +21 -8
  20. package/lib/codegen/template/interpolation.js +5 -3
  21. package/lib/codegen/template/slotOutlet.js +6 -5
  22. package/lib/codegen/template/styleScopedClasses.js +3 -2
  23. package/lib/codegen/template/templateChild.js +2 -1
  24. package/lib/codegen/template/vFor.js +6 -4
  25. package/lib/codegen/template/vIf.js +2 -1
  26. package/lib/codegen/template/vSlot.js +11 -9
  27. package/lib/codegen/tenp.d.ts +1 -0
  28. package/lib/codegen/tenp.js +3 -0
  29. package/lib/codegen/utils/index.d.ts +0 -10
  30. package/lib/codegen/utils/index.js +0 -27
  31. package/lib/parsers/scriptSetupRanges.d.ts +0 -1
  32. package/lib/parsers/scriptSetupRanges.js +4 -40
  33. package/lib/parsers/utils.d.ts +12 -0
  34. package/lib/parsers/utils.js +95 -0
  35. package/lib/plugins/file-css.d.ts +3 -0
  36. package/lib/plugins/file-css.js +57 -0
  37. package/lib/plugins/file-vue.js +16 -1
  38. package/lib/plugins/vue-root-tags.js +2 -9
  39. package/lib/plugins/vue-style-css.d.ts +3 -0
  40. package/lib/plugins/vue-style-css.js +62 -0
  41. package/lib/plugins/vue-tsx.d.ts +2 -20
  42. package/lib/plugins/vue-tsx.js +18 -20
  43. package/lib/types.d.ts +1 -1
  44. package/lib/utils/collectBindings.d.ts +12 -0
  45. package/lib/utils/collectBindings.js +29 -0
  46. package/lib/utils/ts.js +20 -18
  47. package/package.json +4 -4
package/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export * from './lib/codegen/globalTypes';
2
2
  export * from './lib/codegen/template';
3
- export * from './lib/codegen/utils';
4
3
  export * from './lib/languagePlugin';
5
4
  export * from './lib/parsers/scriptSetupRanges';
6
5
  export * from './lib/plugins';
7
6
  export * from './lib/types';
7
+ export * from './lib/utils/collectBindings';
8
8
  export * from './lib/utils/parseSfc';
9
9
  export * from './lib/utils/shared';
10
10
  export * from './lib/utils/ts';
package/index.js CHANGED
@@ -17,11 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.tsCodegen = void 0;
18
18
  __exportStar(require("./lib/codegen/globalTypes"), exports);
19
19
  __exportStar(require("./lib/codegen/template"), exports);
20
- __exportStar(require("./lib/codegen/utils"), exports);
21
20
  __exportStar(require("./lib/languagePlugin"), exports);
22
21
  __exportStar(require("./lib/parsers/scriptSetupRanges"), exports);
23
22
  __exportStar(require("./lib/plugins"), exports);
24
23
  __exportStar(require("./lib/types"), exports);
24
+ __exportStar(require("./lib/utils/collectBindings"), exports);
25
25
  __exportStar(require("./lib/utils/parseSfc"), exports);
26
26
  __exportStar(require("./lib/utils/shared"), exports);
27
27
  __exportStar(require("./lib/utils/ts"), exports);
@@ -25,15 +25,16 @@ declare const raw: {
25
25
  navigation: {
26
26
  navigation: true;
27
27
  };
28
+ navigationWithoutHighlight: {
29
+ navigation: {
30
+ shouldHighlight: () => false;
31
+ };
32
+ };
28
33
  navigationWithoutRename: {
29
34
  navigation: {
30
35
  shouldRename: () => false;
31
36
  };
32
37
  };
33
- navigationAndCompletion: {
34
- navigation: true;
35
- completion: true;
36
- };
37
38
  navigationAndAdditionalCompletion: {
38
39
  navigation: true;
39
40
  completion: {
@@ -62,13 +63,6 @@ declare const raw: {
62
63
  navigation: true;
63
64
  completion: true;
64
65
  };
65
- withoutHighlightAndNavigation: {
66
- semantic: {
67
- shouldHighlight: () => false;
68
- };
69
- verification: true;
70
- completion: true;
71
- };
72
66
  withoutHighlightAndCompletion: {
73
67
  semantic: {
74
68
  shouldHighlight: () => false;
@@ -76,17 +70,26 @@ declare const raw: {
76
70
  verification: true;
77
71
  navigation: true;
78
72
  };
79
- withoutHighlightAndCompletionAndNavigation: {
80
- semantic: {
81
- shouldHighlight: () => false;
82
- };
83
- verification: true;
84
- };
85
73
  withoutSemantic: {
86
74
  verification: true;
87
75
  navigation: true;
88
76
  completion: true;
89
77
  };
78
+ doNotReportTs2339AndTs2551: {
79
+ verification: {
80
+ shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
81
+ };
82
+ };
83
+ doNotReportTs2353AndTs2561: {
84
+ verification: {
85
+ shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
86
+ };
87
+ };
88
+ doNotReportTs6133: {
89
+ verification: {
90
+ shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
91
+ };
92
+ };
90
93
  };
91
94
  export declare const codeFeatures: { [K in keyof typeof raw]: VueCodeInformation; };
92
95
  export {};
@@ -25,13 +25,12 @@ const raw = {
25
25
  navigation: {
26
26
  navigation: true,
27
27
  },
28
+ navigationWithoutHighlight: {
29
+ navigation: { shouldHighlight: () => false },
30
+ },
28
31
  navigationWithoutRename: {
29
32
  navigation: { shouldRename: () => false },
30
33
  },
31
- navigationAndCompletion: {
32
- navigation: true,
33
- completion: true,
34
- },
35
34
  navigationAndAdditionalCompletion: {
36
35
  navigation: true,
37
36
  completion: { isAdditional: true },
@@ -54,25 +53,36 @@ const raw = {
54
53
  navigation: true,
55
54
  completion: true,
56
55
  },
57
- withoutHighlightAndNavigation: {
58
- semantic: { shouldHighlight: () => false },
59
- verification: true,
60
- completion: true,
61
- },
62
56
  withoutHighlightAndCompletion: {
63
57
  semantic: { shouldHighlight: () => false },
64
58
  verification: true,
65
59
  navigation: true,
66
60
  },
67
- withoutHighlightAndCompletionAndNavigation: {
68
- semantic: { shouldHighlight: () => false },
69
- verification: true,
70
- },
71
61
  withoutSemantic: {
72
62
  verification: true,
73
63
  navigation: true,
74
64
  completion: true,
75
65
  },
66
+ doNotReportTs2339AndTs2551: {
67
+ verification: {
68
+ // https://typescript.tv/errors/#ts2339
69
+ // https://typescript.tv/errors/#ts2551
70
+ shouldReport: (_source, code) => String(code) !== '2339' && String(code) !== '2551',
71
+ },
72
+ },
73
+ doNotReportTs2353AndTs2561: {
74
+ verification: {
75
+ // https://typescript.tv/errors/#ts2353
76
+ // https://typescript.tv/errors/#ts2561
77
+ shouldReport: (_source, code) => String(code) !== '2353' && String(code) !== '2561',
78
+ },
79
+ },
80
+ doNotReportTs6133: {
81
+ verification: {
82
+ // https://typescript.tv/errors/#ts6133
83
+ shouldReport: (_source, code) => String(code) !== '6133',
84
+ },
85
+ },
76
86
  };
77
87
  exports.codeFeatures = raw;
78
88
  //# sourceMappingURL=codeFeatures.js.map
@@ -1,3 +1,3 @@
1
1
  import type { VueCompilerOptions } from '../types';
2
- export declare function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }: VueCompilerOptions): string;
3
- export declare function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }: VueCompilerOptions): string;
2
+ export declare function getGlobalTypesFileName(options: VueCompilerOptions): string;
3
+ export declare function generateGlobalTypes(options: VueCompilerOptions): string;
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGlobalTypesFileName = getGlobalTypesFileName;
4
4
  exports.generateGlobalTypes = generateGlobalTypes;
5
5
  const shared_1 = require("../utils/shared");
6
- function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
6
+ function getGlobalTypesFileName(options) {
7
7
  return [
8
- lib,
9
- target,
10
- checkUnknownProps,
11
- checkUnknownEvents,
12
- checkUnknownComponents,
8
+ options.lib,
9
+ options.target,
10
+ options.checkUnknownProps,
13
11
  ].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
14
12
  }
15
- function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
13
+ function generateGlobalTypes(options) {
14
+ const { lib, target, checkUnknownProps } = options;
16
15
  const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
17
16
  let text = `// @ts-nocheck\nexport {};\n`;
18
17
  if (target < 3.5) {
@@ -50,7 +49,7 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
50
49
  N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
51
50
  N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
52
51
  N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
53
- ${checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }'};
52
+ {};
54
53
  type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
55
54
  ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
56
55
  , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
@@ -61,12 +60,12 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
61
60
  : {};
62
61
  type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
63
62
  __ctx?: {
64
- attrs?: any,
65
- slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>,
66
- emit?: T extends { $emit: infer Emit } ? Emit : {},
67
- props?: ${fnPropsType},
68
- expose?: (exposed: T) => void,
69
- }
63
+ attrs?: any;
64
+ slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>;
65
+ emit?: T extends { $emit: infer Emit } ? Emit : {};
66
+ props?: ${fnPropsType};
67
+ expose?: (exposed: T) => void;
68
+ };
70
69
  };
71
70
  type __VLS_IsFunction<T, K> = K extends keyof T
72
71
  ? __VLS_IsAny<T[K]> extends false
@@ -75,15 +74,19 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
75
74
  : true
76
75
  : false
77
76
  : false;
78
- type __VLS_NormalizeComponentEvent<Props, Emits, onEvent extends keyof Props, Event extends keyof Emits, CamelizedEvent extends keyof Emits> = (
79
- __VLS_IsFunction<Props, onEvent> extends true
80
- ? Props
81
- : __VLS_IsFunction<Emits, Event> extends true
82
- ? { [K in onEvent]?: Emits[Event] }
83
- : __VLS_IsFunction<Emits, CamelizedEvent> extends true
84
- ? { [K in onEvent]?: Emits[CamelizedEvent] }
85
- : Props
86
- )${checkUnknownEvents ? '' : ' & Record<string, unknown>'};
77
+ type __VLS_NormalizeComponentEvent<
78
+ Props,
79
+ Emits,
80
+ onEvent extends keyof Props,
81
+ Event extends keyof Emits,
82
+ CamelizedEvent extends keyof Emits,
83
+ > = __VLS_IsFunction<Props, onEvent> extends true
84
+ ? Props
85
+ : __VLS_IsFunction<Emits, Event> extends true
86
+ ? { [K in onEvent]?: Emits[Event] }
87
+ : __VLS_IsFunction<Emits, CamelizedEvent> extends true
88
+ ? { [K in onEvent]?: Emits[CamelizedEvent] }
89
+ : Props;
87
90
  // fix https://github.com/vuejs/language-tools/issues/926
88
91
  type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
89
92
  type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
@@ -150,7 +153,7 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
150
153
  : T extends (...args: any) => any ? T
151
154
  : __VLS_FunctionalComponent<{}>;
152
155
  function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
153
- function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownComponents ? '' : ' & Record<string, unknown>'}) => void;
156
+ function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownProps ? '' : ' & Record<string, unknown>'}) => void;
154
157
  function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
155
158
  function __VLS_tryAsConstant<const T>(t: T): T;
156
159
  }
@@ -1,11 +1,5 @@
1
1
  import type { InlayHintInfo } from '../inlayHints';
2
2
  import type { ScriptCodegenOptions } from './index';
3
- export interface HelperType {
4
- name: string;
5
- used?: boolean;
6
- generated?: boolean;
7
- code: string;
8
- }
9
3
  export type ScriptCodegenContext = ReturnType<typeof createScriptCodegenContext>;
10
4
  export declare function createScriptCodegenContext(options: ScriptCodegenOptions): {
11
5
  generatedTemplate: boolean;
@@ -4,6 +4,7 @@ import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges';
4
4
  import type { Code, Sfc, VueCompilerOptions } from '../../types';
5
5
  import type { TemplateCodegenContext } from '../template/context';
6
6
  import { type ScriptCodegenContext } from './context';
7
+ export * from './context';
7
8
  export interface ScriptCodegenOptions {
8
9
  ts: typeof ts;
9
10
  compilerOptions: ts.CompilerOptions;
@@ -19,5 +20,5 @@ export interface ScriptCodegenOptions {
19
20
  destructuredPropNames: Set<string>;
20
21
  templateRefNames: Set<string>;
21
22
  }
22
- export declare function generateScript(options: ScriptCodegenOptions): Generator<Code, ScriptCodegenContext>;
23
+ export declare function generateScript(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;
23
24
  export declare function generateScriptSectionPartiallyEnding(source: string, end: number, mark: string, delimiter?: string): Generator<Code>;
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.generateScript = generateScript;
4
18
  exports.generateScriptSectionPartiallyEnding = generateScriptSectionPartiallyEnding;
@@ -6,12 +20,11 @@ const path = require("path-browserify");
6
20
  const codeFeatures_1 = require("../codeFeatures");
7
21
  const utils_1 = require("../utils");
8
22
  const componentSelf_1 = require("./componentSelf");
9
- const context_1 = require("./context");
10
23
  const scriptSetup_1 = require("./scriptSetup");
11
24
  const src_1 = require("./src");
12
25
  const template_1 = require("./template");
13
- function* generateScript(options) {
14
- const ctx = (0, context_1.createScriptCodegenContext)(options);
26
+ __exportStar(require("./context"), exports);
27
+ function* generateScript(options, ctx) {
15
28
  yield* generateGlobalTypesPath(options);
16
29
  if (options.sfc.script?.src) {
17
30
  yield* (0, src_1.generateSrc)(options.sfc.script.src);
@@ -93,7 +106,6 @@ function* generateScript(options) {
93
106
  if (options.sfc.scriptSetup) {
94
107
  yield ['', 'scriptSetup', options.sfc.scriptSetup.content.length, codeFeatures_1.codeFeatures.verification];
95
108
  }
96
- return ctx;
97
109
  }
98
110
  function* generateGlobalTypesPath(options) {
99
111
  const globalTypesPath = options.vueCompilerOptions.globalTypesPath(options.fileName);
@@ -248,10 +248,9 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
248
248
  const templateCodegenCtx = yield* (0, template_1.generateTemplate)(options, ctx);
249
249
  yield* (0, componentSelf_1.generateComponentSelf)(options, ctx, templateCodegenCtx);
250
250
  if (syntax) {
251
- if (!options.vueCompilerOptions.skipTemplateCodegen
252
- && (scriptSetupRanges.defineSlots
253
- || options.templateCodegen?.slots.length
254
- || options.templateCodegen?.dynamicSlots.length)) {
251
+ if (scriptSetupRanges.defineSlots
252
+ || options.templateCodegen?.slots.length
253
+ || options.templateCodegen?.dynamicSlots.length) {
255
254
  yield `const __VLS_component = `;
256
255
  yield* (0, component_1.generateComponent)(options, ctx, scriptSetup, scriptSetupRanges);
257
256
  yield utils_1.endOfLine;
@@ -401,7 +400,7 @@ function* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges) {
401
400
  yield* generateDefineModelType(scriptSetup, propName, localName, defineModel);
402
401
  yield `,${utils_1.newLine}`;
403
402
  if (defineModel.modifierType) {
404
- const modifierName = `${defineModel.name ? propName : 'model'}Modifiers`;
403
+ const modifierName = `${propName === 'modelValue' ? 'model' : propName}Modifiers`;
405
404
  const modifierType = getRangeText(scriptSetup, defineModel.modifierType);
406
405
  yield `'${modifierName}'?: Partial<Record<${modifierType}, true>>,${utils_1.newLine}`;
407
406
  }
@@ -112,25 +112,6 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
112
112
  offset: number;
113
113
  };
114
114
  };
115
- codeFeatures: {
116
- all: VueCodeInformation;
117
- verification: VueCodeInformation;
118
- completion: VueCodeInformation;
119
- additionalCompletion: VueCodeInformation;
120
- withoutCompletion: VueCodeInformation;
121
- navigation: VueCodeInformation;
122
- navigationWithoutRename: VueCodeInformation;
123
- navigationAndCompletion: VueCodeInformation;
124
- navigationAndAdditionalCompletion: VueCodeInformation;
125
- navigationAndVerification: VueCodeInformation;
126
- withoutNavigation: VueCodeInformation;
127
- semanticWithoutHighlight: VueCodeInformation;
128
- withoutHighlight: VueCodeInformation;
129
- withoutHighlightAndNavigation: VueCodeInformation;
130
- withoutHighlightAndCompletion: VueCodeInformation;
131
- withoutHighlightAndCompletionAndNavigation: VueCodeInformation;
132
- withoutSemantic: VueCodeInformation;
133
- };
134
115
  resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation;
135
116
  inlineTsAsts: Map<string, import("typescript").SourceFile> | undefined;
136
117
  inVFor: boolean;
@@ -154,12 +154,6 @@ function createTemplateCodegenContext(options, templateAst) {
154
154
  get currentInfo() {
155
155
  return stack[stack.length - 1];
156
156
  },
157
- codeFeatures: new Proxy(codeFeatures_1.codeFeatures, {
158
- get(target, key) {
159
- const data = target[key];
160
- return resolveCodeFeatures(data);
161
- },
162
- }),
163
157
  resolveCodeFeatures,
164
158
  inlineTsAsts: templateAst && computedSfc_1.templateInlineTsAsts.get(templateAst),
165
159
  inVFor: false,
@@ -76,12 +76,12 @@ function* generateComponent(options, ctx, node) {
76
76
  componentOriginalVar,
77
77
  'template',
78
78
  tagOffset,
79
- ctx.codeFeatures.withoutHighlightAndCompletion,
79
+ codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
80
80
  ];
81
81
  }
82
82
  else {
83
83
  const shouldCapitalize = matchImportName[0].toUpperCase() === matchImportName[0];
84
- yield* (0, camelized_1.generateCamelized)(shouldCapitalize ? (0, shared_1.capitalize)(node.tag) : node.tag, 'template', tagOffset, ctx.codeFeatures.withoutHighlightAndCompletion);
84
+ yield* (0, camelized_1.generateCamelized)(shouldCapitalize ? (0, shared_1.capitalize)(node.tag) : node.tag, 'template', tagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
85
85
  }
86
86
  yield `, `;
87
87
  }
@@ -89,10 +89,10 @@ function* generateComponent(options, ctx, node) {
89
89
  }
90
90
  else if (dynamicTagInfo) {
91
91
  yield `const ${componentOriginalVar} = (`;
92
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, dynamicTagInfo.tag, dynamicTagInfo.offsets[0], `(`, `)`);
92
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, dynamicTagInfo.tag, dynamicTagInfo.offsets[0], `(`, `)`);
93
93
  if (dynamicTagInfo.offsets[1] !== undefined) {
94
94
  yield `,`;
95
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.withoutCompletion, dynamicTagInfo.tag, dynamicTagInfo.offsets[1], `(`, `)`);
95
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.withoutCompletion, dynamicTagInfo.tag, dynamicTagInfo.offsets[1], `(`, `)`);
96
96
  }
97
97
  yield `)${utils_1.endOfLine}`;
98
98
  }
@@ -110,7 +110,12 @@ function* generateComponent(options, ctx, node) {
110
110
  .map(name => `'${name}'`)
111
111
  .join(`, `);
112
112
  yield `>).`;
113
- yield* generateCanonicalComponentName(node.tag, tagOffsets[0], ctx.codeFeatures.withoutHighlightAndCompletionAndNavigation);
113
+ yield* generateCanonicalComponentName(node.tag, tagOffsets[0], {
114
+ ...codeFeatures_1.codeFeatures.semanticWithoutHighlight,
115
+ ...options.vueCompilerOptions.checkUnknownComponents
116
+ ? codeFeatures_1.codeFeatures.verification
117
+ : codeFeatures_1.codeFeatures.doNotReportTs2339AndTs2551,
118
+ });
114
119
  yield `${utils_1.endOfLine}`;
115
120
  const camelizedTag = (0, shared_1.camelize)(node.tag);
116
121
  if (utils_1.identifierRegex.test(camelizedTag)) {
@@ -140,18 +145,11 @@ function* generateComponent(options, ctx, node) {
140
145
  yield* (0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, false);
141
146
  yield `}))${utils_1.endOfLine}`;
142
147
  yield `const `;
143
- yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, ctx.resolveCodeFeatures({
144
- verification: {
145
- shouldReport(_source, code) {
146
- // https://typescript.tv/errors/#ts6133
147
- return String(code) !== '6133';
148
- },
149
- },
150
- }), componentVNodeVar);
148
+ yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.doNotReportTs6133, componentVNodeVar);
151
149
  yield ` = ${componentFunctionalVar}`;
152
150
  yield* generateComponentGeneric(ctx);
153
151
  yield `(`;
154
- yield* (0, wrapWith_1.wrapWith)(tagOffsets[0], tagOffsets[0] + node.tag.length, ctx.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
152
+ yield* (0, wrapWith_1.wrapWith)(tagOffsets[0], tagOffsets[0] + node.tag.length, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
155
153
  yield `, ...__VLS_functionalComponentArgsRest(${componentFunctionalVar}))${utils_1.endOfLine}`;
156
154
  yield* generateFailedPropExps(options, ctx, failedPropExps);
157
155
  yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentOriginalVar, componentFunctionalVar, componentVNodeVar, componentCtxVar);
@@ -194,14 +192,18 @@ function* generateElement(options, ctx, node) {
194
192
  ? node.loc.start.offset + node.loc.source.lastIndexOf(node.tag)
195
193
  : undefined;
196
194
  const failedPropExps = [];
195
+ const features = {
196
+ ...codeFeatures_1.codeFeatures.semanticWithoutHighlight,
197
+ ...codeFeatures_1.codeFeatures.navigationWithoutHighlight,
198
+ };
197
199
  yield `__VLS_asFunctionalElement(__VLS_elements`;
198
- yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, ctx.codeFeatures.withoutHighlightAndCompletion);
200
+ yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, features);
199
201
  if (endTagOffset !== undefined) {
200
202
  yield `, __VLS_elements`;
201
- yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, ctx.codeFeatures.withoutHighlightAndCompletion);
203
+ yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, features);
202
204
  }
203
205
  yield `)(`;
204
- yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagOffset + node.tag.length, ctx.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
206
+ yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagOffset + node.tag.length, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
205
207
  yield `)${utils_1.endOfLine}`;
206
208
  yield* generateFailedPropExps(options, ctx, failedPropExps);
207
209
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
@@ -227,7 +229,7 @@ function* generateElement(options, ctx, node) {
227
229
  }
228
230
  function* generateFailedPropExps(options, ctx, failedPropExps) {
229
231
  for (const failedExp of failedPropExps) {
230
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, failedExp.node.loc.source, failedExp.node.loc.start.offset, failedExp.prefix, failedExp.suffix);
232
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, failedExp.node.loc.source, failedExp.node.loc.start.offset, failedExp.prefix, failedExp.suffix);
231
233
  yield utils_1.endOfLine;
232
234
  }
233
235
  }
@@ -260,11 +262,11 @@ function* generateCanonicalComponentName(tagText, offset, features) {
260
262
  function* generateComponentGeneric(ctx) {
261
263
  if (ctx.currentInfo.generic) {
262
264
  const { content, offset } = ctx.currentInfo.generic;
263
- yield* (0, wrapWith_1.wrapWith)(offset, offset + content.length, ctx.codeFeatures.verification, `<`, [
265
+ yield* (0, wrapWith_1.wrapWith)(offset, offset + content.length, codeFeatures_1.codeFeatures.verification, `<`, [
264
266
  content,
265
267
  'template',
266
268
  offset,
267
- ctx.codeFeatures.all,
269
+ codeFeatures_1.codeFeatures.all,
268
270
  ], `>`);
269
271
  }
270
272
  }
@@ -276,7 +278,7 @@ function* generateElementReference(options, ctx, node) {
276
278
  const [content, startOffset] = (0, utils_1.normalizeAttributeValue)(prop.value);
277
279
  // navigation support for `const foo = ref()`
278
280
  yield `/** @type {typeof __VLS_ctx`;
279
- yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset, ctx.codeFeatures.navigation);
281
+ yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset, codeFeatures_1.codeFeatures.navigation);
280
282
  yield `} */${utils_1.endOfLine}`;
281
283
  if (utils_1.identifierRegex.test(content) && !options.templateRefNames.has(content)) {
282
284
  ctx.accessExternalVariable(content, startOffset);
@@ -30,16 +30,16 @@ function* generateElementDirectives(options, ctx, node) {
30
30
  continue;
31
31
  }
32
32
  ctx.accessExternalVariable((0, shared_1.camelize)('v-' + prop.name), prop.loc.start.offset);
33
- yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, `__VLS_asFunctionalDirective(`, ...generateIdentifier(options, ctx, prop), `)(null!, { ...__VLS_directiveBindingRestFields, `, ...generateArg(options, ctx, prop), ...generateModifiers(options, ctx, prop), ...generateValue(options, ctx, prop), ` }, null!, null!)`);
33
+ yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, codeFeatures_1.codeFeatures.verification, `__VLS_asFunctionalDirective(`, ...generateIdentifier(options, prop), `)(null!, { ...__VLS_directiveBindingRestFields, `, ...generateArg(options, ctx, prop), ...generateModifiers(options, ctx, prop), ...generateValue(options, ctx, prop), ` }, null!, null!)`);
34
34
  yield utils_1.endOfLine;
35
35
  }
36
36
  }
37
- function* generateIdentifier(options, ctx, prop) {
37
+ function* generateIdentifier(options, prop) {
38
38
  const rawName = 'v-' + prop.name;
39
- yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + rawName.length, ctx.codeFeatures.verification, `__VLS_directives.`, ...(0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, ctx.resolveCodeFeatures({
39
+ yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + rawName.length, codeFeatures_1.codeFeatures.verification, `__VLS_directives.`, ...(0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, {
40
40
  ...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
41
41
  verification: options.vueCompilerOptions.checkUnknownDirectives && !builtInDirectives.has(prop.name),
42
- })));
42
+ }));
43
43
  }
44
44
  function* generateArg(options, ctx, prop) {
45
45
  const { arg } = prop;
@@ -47,13 +47,13 @@ function* generateArg(options, ctx, prop) {
47
47
  return;
48
48
  }
49
49
  const startOffset = arg.loc.start.offset + arg.loc.source.indexOf(arg.content);
50
- yield* (0, wrapWith_1.wrapWith)(startOffset, startOffset + arg.content.length, ctx.codeFeatures.verification, `arg`);
50
+ yield* (0, wrapWith_1.wrapWith)(startOffset, startOffset + arg.content.length, codeFeatures_1.codeFeatures.verification, `arg`);
51
51
  yield `: `;
52
52
  if (arg.isStatic) {
53
- yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, ctx.codeFeatures.all);
53
+ yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, codeFeatures_1.codeFeatures.all);
54
54
  }
55
55
  else {
56
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, arg.content, startOffset, `(`, `)`);
56
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, arg.content, startOffset, `(`, `)`);
57
57
  }
58
58
  yield `, `;
59
59
  }
@@ -64,10 +64,10 @@ function* generateModifiers(options, ctx, prop, propertyName = 'modifiers') {
64
64
  }
65
65
  const startOffset = modifiers[0].loc.start.offset - 1;
66
66
  const endOffset = modifiers.at(-1).loc.end.offset;
67
- yield* (0, wrapWith_1.wrapWith)(startOffset, endOffset, ctx.codeFeatures.verification, propertyName);
67
+ yield* (0, wrapWith_1.wrapWith)(startOffset, endOffset, codeFeatures_1.codeFeatures.verification, propertyName);
68
68
  yield `: { `;
69
69
  for (const mod of modifiers) {
70
- yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, ctx.codeFeatures.withoutHighlightAndNavigation);
70
+ yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlight);
71
71
  yield `: true, `;
72
72
  }
73
73
  yield `}, `;
@@ -77,7 +77,7 @@ function* generateValue(options, ctx, prop) {
77
77
  if (exp?.type !== CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
78
78
  return;
79
79
  }
80
- yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, ctx.codeFeatures.verification, `value`);
80
+ yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification, `value`);
81
81
  yield `: `;
82
82
  yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
83
83
  }
@@ -4,7 +4,7 @@ import type { Code, VueCodeInformation } from '../../types';
4
4
  import type { TemplateCodegenContext } from './context';
5
5
  import type { TemplateCodegenOptions } from './index';
6
6
  export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentOriginalVar: string, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
7
- export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>;
7
+ export declare function generateEventArg(options: TemplateCodegenOptions, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>;
8
8
  export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
9
9
  export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
10
10
  export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean;