@vue/language-core 3.0.0-alpha.0 → 3.0.0-alpha.10

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 (60) hide show
  1. package/lib/codegen/codeFeatures.d.ts +5 -0
  2. package/lib/codegen/codeFeatures.js +5 -0
  3. package/lib/codegen/globalTypes.js +44 -30
  4. package/lib/codegen/localTypes.d.ts +2 -3
  5. package/lib/codegen/localTypes.js +5 -15
  6. package/lib/codegen/script/component.js +21 -9
  7. package/lib/codegen/script/context.d.ts +1 -1
  8. package/lib/codegen/script/context.js +1 -1
  9. package/lib/codegen/script/index.d.ts +1 -1
  10. package/lib/codegen/script/index.js +2 -15
  11. package/lib/codegen/script/scriptSetup.js +5 -16
  12. package/lib/codegen/script/src.js +4 -3
  13. package/lib/codegen/script/template.js +3 -5
  14. package/lib/codegen/template/context.d.ts +28 -18
  15. package/lib/codegen/template/context.js +87 -53
  16. package/lib/codegen/template/element.d.ts +2 -2
  17. package/lib/codegen/template/element.js +20 -30
  18. package/lib/codegen/template/elementChildren.d.ts +2 -2
  19. package/lib/codegen/template/elementChildren.js +4 -6
  20. package/lib/codegen/template/elementDirectives.js +3 -7
  21. package/lib/codegen/template/elementEvents.d.ts +3 -3
  22. package/lib/codegen/template/elementEvents.js +25 -18
  23. package/lib/codegen/template/elementProps.d.ts +2 -2
  24. package/lib/codegen/template/elementProps.js +8 -15
  25. package/lib/codegen/template/index.d.ts +1 -1
  26. package/lib/codegen/template/index.js +22 -11
  27. package/lib/codegen/template/interpolation.d.ts +1 -1
  28. package/lib/codegen/template/interpolation.js +52 -50
  29. package/lib/codegen/template/slotOutlet.js +2 -3
  30. package/lib/codegen/template/templateChild.d.ts +1 -1
  31. package/lib/codegen/template/templateChild.js +12 -46
  32. package/lib/codegen/template/vFor.js +5 -10
  33. package/lib/codegen/template/vIf.js +2 -10
  34. package/lib/codegen/template/vSlot.d.ts +1 -2
  35. package/lib/codegen/template/vSlot.js +111 -59
  36. package/lib/codegen/utils/index.d.ts +2 -3
  37. package/lib/codegen/utils/index.js +0 -16
  38. package/lib/languagePlugin.d.ts +1 -1
  39. package/lib/languagePlugin.js +1 -7
  40. package/lib/parsers/scriptRanges.d.ts +2 -3
  41. package/lib/parsers/scriptRanges.js +3 -10
  42. package/lib/parsers/scriptSetupRanges.js +27 -22
  43. package/lib/plugins/file-md.js +3 -0
  44. package/lib/plugins/vue-style-css.d.ts +3 -0
  45. package/lib/plugins/vue-style-css.js +18 -0
  46. package/lib/plugins/vue-template-inline-css.js +1 -1
  47. package/lib/plugins/vue-template-inline-ts.js +5 -2
  48. package/lib/plugins/vue-tsx.d.ts +27 -18
  49. package/lib/plugins/vue-tsx.js +32 -20
  50. package/lib/plugins.d.ts +1 -1
  51. package/lib/types.d.ts +2 -1
  52. package/lib/utils/shared.d.ts +0 -1
  53. package/lib/utils/shared.js +0 -4
  54. package/lib/utils/signals.d.ts +1 -0
  55. package/lib/utils/signals.js +11 -0
  56. package/lib/utils/ts.js +3 -4
  57. package/lib/virtualFile/computedSfc.js +6 -6
  58. package/package.json +6 -8
  59. package/lib/utils/vue2TemplateCompiler.d.ts +0 -2
  60. package/lib/utils/vue2TemplateCompiler.js +0 -89
@@ -78,6 +78,11 @@ declare const raw: {
78
78
  };
79
79
  verification: true;
80
80
  };
81
+ withoutSemantic: {
82
+ verification: true;
83
+ navigation: true;
84
+ completion: true;
85
+ };
81
86
  };
82
87
  export declare const codeFeatures: { [K in keyof typeof raw]: VueCodeInformation; };
83
88
  export {};
@@ -66,6 +66,11 @@ const raw = {
66
66
  semantic: { shouldHighlight: () => false },
67
67
  verification: true,
68
68
  },
69
+ withoutSemantic: {
70
+ verification: true,
71
+ navigation: true,
72
+ completion: true,
73
+ },
69
74
  };
70
75
  exports.codeFeatures = raw;
71
76
  //# sourceMappingURL=codeFeatures.js.map
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGlobalTypesFileName = getGlobalTypesFileName;
4
4
  exports.generateGlobalTypes = generateGlobalTypes;
5
- const shared_1 = require("../utils/shared");
6
5
  function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
7
6
  return [
8
7
  lib,
@@ -13,7 +12,7 @@ function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEv
13
12
  ].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
14
13
  }
15
14
  function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
16
- const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
15
+ const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
17
16
  let text = ``;
18
17
  if (target < 3.5) {
19
18
  text += `
@@ -51,10 +50,31 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
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
52
  ${checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }'};
54
- type __VLS_FunctionalComponentProps<T, K> =
55
- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
56
- : T extends (props: infer P, ...args: any) => any ? P :
57
- {};
53
+ type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
54
+ ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
55
+ , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
56
+ >;
57
+ type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}>
58
+ ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
59
+ : T extends (props: infer P, ...args: any) => any ? P
60
+ : {};
61
+ type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
62
+ __ctx?: {
63
+ attrs?: any,
64
+ slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>,
65
+ emit?: T extends { $emit: infer Emit } ? Emit : {},
66
+ props?: ${fnPropsType},
67
+ expose?: (exposed: T) => void,
68
+ }
69
+ };
70
+ type __VLS_NormalizeSlotReturns<S, R = NonNullable<S> extends (...args: any) => infer K ? K : any> = R extends any[] ? {
71
+ [K in keyof R]: R[K] extends infer V
72
+ ? V extends Element ? V
73
+ : V extends new (...args: any) => infer R ? ReturnType<__VLS_FunctionalComponent<R>>
74
+ : V extends (...args: any) => infer R ? R
75
+ : any
76
+ : never
77
+ } : R;
58
78
  type __VLS_IsFunction<T, K> = K extends keyof T
59
79
  ? __VLS_IsAny<T[K]> extends false
60
80
  ? unknown extends T[K]
@@ -62,13 +82,13 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
62
82
  : true
63
83
  : false
64
84
  : false;
65
- type __VLS_NormalizeComponentEvent<Props, Events, onEvent extends keyof Props, Event extends keyof Events, CamelizedEvent extends keyof Events> = (
85
+ type __VLS_NormalizeComponentEvent<Props, Emits, onEvent extends keyof Props, Event extends keyof Emits, CamelizedEvent extends keyof Emits> = (
66
86
  __VLS_IsFunction<Props, onEvent> extends true
67
87
  ? Props
68
- : __VLS_IsFunction<Events, Event> extends true
69
- ? { [K in onEvent]?: Events[Event] }
70
- : __VLS_IsFunction<Events, CamelizedEvent> extends true
71
- ? { [K in onEvent]?: Events[CamelizedEvent] }
88
+ : __VLS_IsFunction<Emits, Event> extends true
89
+ ? { [K in onEvent]?: Emits[Event] }
90
+ : __VLS_IsFunction<Emits, CamelizedEvent> extends true
91
+ ? { [K in onEvent]?: Emits[CamelizedEvent] }
72
92
  : Props
73
93
  )${checkUnknownEvents ? '' : ' & Record<string, unknown>'};
74
94
  // fix https://github.com/vuejs/language-tools/issues/926
@@ -94,11 +114,16 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
94
114
  }
95
115
  >
96
116
  >;
117
+ type __VLS_ResolveEmits<
118
+ Comp,
119
+ Emits,
120
+ TypeEmits = ${target >= 3.6 ? `Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('${lib}').ShortEmitsToObject<T> : {}` : `{}`},
121
+ NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
122
+ > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
123
+ type __VLS_ResolveDirectives<T> = {
124
+ [K in Exclude<keyof T, keyof __VLS_GlobalDirectives> & string as \`v\${Capitalize<K>}\`]: T[K];
125
+ };
97
126
  type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
98
- type __VLS_PickFunctionalComponentCtx<T, K> = NonNullable<__VLS_PickNotAny<
99
- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
100
- , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
101
- >>;
102
127
  type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
103
128
 
104
129
  function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
@@ -114,10 +139,8 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
114
139
  key: keyof T,
115
140
  index: number,
116
141
  ][];
117
- // @ts-ignore
118
- function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
119
- // @ts-ignore
120
- function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
142
+ function __VLS_getSlotParameters<S, D extends S>(slot: S, decl?: D):
143
+ __VLS_PickNotAny<NonNullable<D>, (...args: any) => any> extends (...args: infer P) => any ? P : any[];
121
144
  function __VLS_asFunctionalDirective<T>(dir: T): T extends import('${lib}').ObjectDirective
122
145
  ? NonNullable<T['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>
123
146
  : T extends (...args: any) => any
@@ -125,19 +148,10 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
125
148
  : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
126
149
  function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
127
150
  function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
128
- T extends new (...args: any) => any
129
- ? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
130
- __ctx?: {
131
- attrs?: any;
132
- slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : any;
133
- emit?: K extends { $emit: infer Emit } ? Emit : any;
134
- expose?(exposed: K): void;
135
- props?: ${fnPropsType};
136
- }
137
- }
151
+ T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
138
152
  : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
139
153
  : T extends (...args: any) => any ? T
140
- : (_: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'} } };
154
+ : __VLS_FunctionalComponent<{}>;
141
155
  function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
142
156
  function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownComponents ? '' : ' & Record<string, unknown>'}) => void;
143
157
  function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
@@ -1,6 +1,5 @@
1
- import type * as ts from 'typescript';
2
- import { VueCompilerOptions } from '../types';
3
- export declare function getLocalTypesGenerator(compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions): {
1
+ import type { VueCompilerOptions } from '../types';
2
+ export declare function getLocalTypesGenerator(vueCompilerOptions: VueCompilerOptions): {
4
3
  generate: (names: string[]) => Generator<string, void, unknown>;
5
4
  getUsedNames(): Set<string>;
6
5
  readonly PrettifyLocal: string;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalTypesGenerator = getLocalTypesGenerator;
4
- const shared_1 = require("../utils/shared");
5
4
  const utils_1 = require("./utils");
6
- function getLocalTypesGenerator(compilerOptions, vueCompilerOptions) {
5
+ function getLocalTypesGenerator(vueCompilerOptions) {
7
6
  const used = new Set();
8
7
  const OmitKeepDiscriminatedUnion = defineHelper(`__VLS_OmitKeepDiscriminatedUnion`, () => `
9
8
  type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
@@ -13,7 +12,7 @@ type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
13
12
  const WithDefaults = defineHelper(`__VLS_WithDefaults`, () => `
14
13
  type __VLS_WithDefaults<P, D> = {
15
14
  [K in keyof Pick<P, keyof P>]: K extends keyof D
16
- ? ${PrettifyLocal.name}<P[K] & { default: D[K]}>
15
+ ? ${PrettifyLocal.name}<P[K] & { default: D[K] }>
17
16
  : P[K]
18
17
  };
19
18
  `.trimStart());
@@ -21,7 +20,7 @@ type __VLS_WithDefaults<P, D> = {
21
20
  const WithSlots = defineHelper(`__VLS_WithSlots`, () => `
22
21
  type __VLS_WithSlots<T, S> = T & {
23
22
  new(): {
24
- ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: S;
23
+ $slots: S;
25
24
  ${vueCompilerOptions.jsxSlots ? `$props: ${PropsChildren.name}<S>;` : ''}
26
25
  }
27
26
  };
@@ -41,19 +40,10 @@ type __VLS_PropsChildren<S> = {
41
40
  )]?: S;
42
41
  };
43
42
  `.trimStart());
44
- const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () => compilerOptions.exactOptionalPropertyTypes ?
45
- `
43
+ const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () => `
46
44
  type __VLS_TypePropsToOption<T> = {
47
45
  [K in keyof T]-?: {} extends Pick<T, K>
48
- ? { type: import('${vueCompilerOptions.lib}').PropType<T[K]> }
49
- : { type: import('${vueCompilerOptions.lib}').PropType<T[K]>, required: true }
50
- };
51
- `.trimStart() :
52
- `
53
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
54
- type __VLS_TypePropsToOption<T> = {
55
- [K in keyof T]-?: {} extends Pick<T, K>
56
- ? { type: import('${vueCompilerOptions.lib}').PropType<__VLS_NonUndefinedable<T[K]>> }
46
+ ? { type: import('${vueCompilerOptions.lib}').PropType<Required<T>[K]> }
57
47
  : { type: import('${vueCompilerOptions.lib}').PropType<T[K]>, required: true }
58
48
  };
59
49
  `.trimStart());
@@ -111,15 +111,23 @@ function* generateEmitsOption(options, scriptSetupRanges) {
111
111
  function* generatePropsOption(options, ctx, scriptSetup, scriptSetupRanges, hasEmitsOption, inheritAttrs) {
112
112
  const codes = [];
113
113
  if (ctx.generatedPropsType) {
114
- codes.push({
115
- optionExp: [
116
- `{} as `,
117
- scriptSetupRanges.withDefaults?.arg ? `${ctx.localTypes.WithDefaults}<` : '',
118
- `${ctx.localTypes.TypePropsToOption}<__VLS_PublicProps>`,
119
- scriptSetupRanges.withDefaults?.arg ? `, typeof __VLS_withDefaultsArg>` : '',
120
- ].join(''),
121
- typeOptionExp: `{} as __VLS_PublicProps`,
122
- });
114
+ if (options.vueCompilerOptions.target >= 3.6) {
115
+ codes.push({
116
+ optionExp: '{}',
117
+ typeOptionExp: `{} as __VLS_PublicProps`,
118
+ });
119
+ }
120
+ else {
121
+ codes.push({
122
+ optionExp: [
123
+ `{} as `,
124
+ scriptSetupRanges.withDefaults?.arg ? `${ctx.localTypes.WithDefaults}<` : '',
125
+ `${ctx.localTypes.TypePropsToOption}<__VLS_PublicProps>`,
126
+ scriptSetupRanges.withDefaults?.arg ? `, typeof __VLS_withDefaultsArg>` : '',
127
+ ].join(''),
128
+ typeOptionExp: `{} as __VLS_PublicProps`,
129
+ });
130
+ }
123
131
  }
124
132
  if (scriptSetupRanges.defineProps?.arg) {
125
133
  const { arg } = scriptSetupRanges.defineProps;
@@ -146,6 +154,10 @@ function* generatePropsOption(options, ctx, scriptSetup, scriptSetupRanges, hasE
146
154
  const useTypeOption = options.vueCompilerOptions.target >= 3.5 && codes.every(code => code.typeOptionExp);
147
155
  const useOption = !useTypeOption || scriptSetupRanges.withDefaults;
148
156
  if (useTypeOption) {
157
+ if (options.vueCompilerOptions.target >= 3.6
158
+ && scriptSetupRanges.withDefaults?.arg) {
159
+ yield `__defaults: __VLS_withDefaultsArg,${utils_1.newLine}`;
160
+ }
149
161
  if (codes.length === 1) {
150
162
  yield `__typeProps: `;
151
163
  yield codes[0].typeOptionExp;
@@ -1,4 +1,4 @@
1
- import { InlayHintInfo } from '../inlayHints';
1
+ import type { InlayHintInfo } from '../inlayHints';
2
2
  import type { ScriptCodegenOptions } from './index';
3
3
  export interface HelperType {
4
4
  name: string;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createScriptCodegenContext = createScriptCodegenContext;
4
4
  const localTypes_1 = require("../localTypes");
5
5
  function createScriptCodegenContext(options) {
6
- const localTypes = (0, localTypes_1.getLocalTypesGenerator)(options.compilerOptions, options.vueCompilerOptions);
6
+ const localTypes = (0, localTypes_1.getLocalTypesGenerator)(options.vueCompilerOptions);
7
7
  const inlayHints = [];
8
8
  return {
9
9
  generatedTemplate: false,
@@ -3,7 +3,7 @@ import type { ScriptRanges } from '../../parsers/scriptRanges';
3
3
  import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges';
4
4
  import type { Code, Sfc, VueCompilerOptions } from '../../types';
5
5
  import type { TemplateCodegenContext } from '../template/context';
6
- import { ScriptCodegenContext } from './context';
6
+ import { type ScriptCodegenContext } from './context';
7
7
  export interface ScriptCodegenOptions {
8
8
  ts: typeof ts;
9
9
  compilerOptions: ts.CompilerOptions;
@@ -27,7 +27,7 @@ function* generateScript(options) {
27
27
  }
28
28
  }
29
29
  else {
30
- yield `/* placeholder */`;
30
+ yield `/// <reference path="./__VLS_fake.d.ts" />`;
31
31
  }
32
32
  if (options.sfc.script?.src) {
33
33
  yield* (0, src_1.generateSrc)(options.sfc.script.src);
@@ -36,7 +36,7 @@ function* generateScript(options) {
36
36
  yield* (0, scriptSetup_1.generateScriptSetupImports)(options.sfc.scriptSetup, options.scriptSetupRanges);
37
37
  }
38
38
  if (options.sfc.script && options.scriptRanges) {
39
- const { exportDefault, classBlockEnd } = options.scriptRanges;
39
+ const { exportDefault } = options.scriptRanges;
40
40
  const isExportRawObject = exportDefault
41
41
  && options.sfc.script.content[exportDefault.expression.start] === '{';
42
42
  if (options.sfc.scriptSetup && options.scriptSetupRanges) {
@@ -77,19 +77,6 @@ function* generateScript(options) {
77
77
  yield options.vueCompilerOptions.optionsWrapper[1];
78
78
  yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, exportDefault.expression.end, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
79
79
  }
80
- else if (classBlockEnd !== undefined) {
81
- if (options.vueCompilerOptions.skipTemplateCodegen) {
82
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
83
- }
84
- else {
85
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, classBlockEnd, codeFeatures_1.codeFeatures.all);
86
- yield `__VLS_template = () => {${utils_1.newLine}`;
87
- const templateCodegenCtx = yield* (0, template_1.generateTemplate)(options, ctx);
88
- yield* (0, componentSelf_1.generateComponentSelf)(options, ctx, templateCodegenCtx);
89
- yield `}${utils_1.endOfLine}`;
90
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, classBlockEnd, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
91
- }
92
- }
93
80
  else {
94
81
  yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
95
82
  yield* generateScriptSectionPartiallyEnding(options.sfc.script.name, options.sfc.script.content.length, '#3632/script.vue');
@@ -78,15 +78,6 @@ function* generateScriptSetup(options, ctx, scriptSetup, scriptSetupRanges) {
78
78
  }
79
79
  function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, syntax) {
80
80
  let setupCodeModifies = [];
81
- for (const { comments } of scriptSetupRanges.defineProp) {
82
- if (comments) {
83
- setupCodeModifies.push([
84
- [``],
85
- comments.start,
86
- comments.end,
87
- ]);
88
- }
89
- }
90
81
  if (scriptSetupRanges.defineProps) {
91
82
  const { name, statement, callExp, typeArg } = scriptSetupRanges.defineProps;
92
83
  setupCodeModifies.push(...generateDefineWithType(scriptSetup, statement, scriptSetupRanges.withDefaults?.callExp ?? callExp, typeArg, name, `__VLS_props`, `__VLS_Props`));
@@ -196,7 +187,7 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
196
187
  const templateRefType = arg
197
188
  ? [
198
189
  `__VLS_TemplateRefs[`,
199
- (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.all),
190
+ (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.withoutSemantic),
200
191
  `]`
201
192
  ]
202
193
  : [`unknown`];
@@ -349,11 +340,9 @@ function* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges) {
349
340
  yield `})${utils_1.endOfLine}`;
350
341
  yield `type __VLS_BuiltInPublicProps = ${options.vueCompilerOptions.target >= 3.4
351
342
  ? `import('${options.vueCompilerOptions.lib}').PublicProps`
352
- : options.vueCompilerOptions.target >= 3.0
353
- ? `import('${options.vueCompilerOptions.lib}').VNodeProps`
354
- + ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps`
355
- + ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps`
356
- : `globalThis.JSX.IntrinsicAttributes`}`;
343
+ : `import('${options.vueCompilerOptions.lib}').VNodeProps`
344
+ + ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps`
345
+ + ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps`}`;
357
346
  yield utils_1.endOfLine;
358
347
  yield `type __VLS_OwnProps = `;
359
348
  yield `${ctx.localTypes.OmitKeepDiscriminatedUnion}<InstanceType<typeof __VLS_fnComponent>['$props'], keyof __VLS_BuiltInPublicProps>`;
@@ -405,7 +394,7 @@ function* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges) {
405
394
  for (const defineProp of scriptSetupRanges.defineProp) {
406
395
  const [propName, localName] = getPropAndLocalName(scriptSetup, defineProp);
407
396
  if (defineProp.comments) {
408
- yield (0, utils_1.generateSfcBlockSection)(scriptSetup, defineProp.comments.start, defineProp.comments.end, codeFeatures_1.codeFeatures.all);
397
+ yield scriptSetup.content.slice(defineProp.comments.start, defineProp.comments.end);
409
398
  yield utils_1.newLine;
410
399
  }
411
400
  if (defineProp.isModel && !defineProp.name) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSrc = generateSrc;
4
4
  const codeFeatures_1 = require("../codeFeatures");
5
5
  const utils_1 = require("../utils");
6
+ const wrapWith_1 = require("../utils/wrapWith");
6
7
  function* generateSrc(src) {
7
8
  if (src === true) {
8
9
  return;
@@ -21,10 +22,10 @@ function* generateSrc(src) {
21
22
  text = text + '.js';
22
23
  }
23
24
  yield `export * from `;
24
- yield* (0, utils_1.generateSfcBlockAttrValue)(src, text, {
25
+ yield* (0, wrapWith_1.wrapWith)(src.offset, src.offset + src.text.length, 'main', {
25
26
  ...codeFeatures_1.codeFeatures.all,
26
- ...text === src.text ? codeFeatures_1.codeFeatures.navigation : codeFeatures_1.codeFeatures.navigationWithoutRename,
27
- });
27
+ ...text !== src.text ? codeFeatures_1.codeFeatures.navigationWithoutRename : {},
28
+ }, `'`, [text.slice(0, src.text.length), 'main', src.offset, utils_1.combineLastMapping], text.slice(src.text.length), `'`);
28
29
  yield utils_1.endOfLine;
29
30
  yield `export { default } from '${text}'${utils_1.endOfLine}`;
30
31
  }
@@ -51,7 +51,7 @@ function* generateTemplateElements() {
51
51
  yield `let __VLS_elements!: __VLS_IntrinsicElements${utils_1.endOfLine}`;
52
52
  }
53
53
  function* generateTemplateComponents(options) {
54
- const types = [];
54
+ const types = [`typeof __VLS_ctx`];
55
55
  if (options.sfc.script && options.scriptRanges?.exportDefault?.componentsOption) {
56
56
  const { componentsOption } = options.scriptRanges.exportDefault;
57
57
  yield `const __VLS_componentsOption = `;
@@ -64,7 +64,6 @@ function* generateTemplateComponents(options) {
64
64
  yield utils_1.endOfLine;
65
65
  types.push(`typeof __VLS_componentsOption`);
66
66
  }
67
- types.push(`typeof __VLS_ctx`);
68
67
  yield `type __VLS_LocalComponents =`;
69
68
  for (const type of types) {
70
69
  yield ` & `;
@@ -74,7 +73,7 @@ function* generateTemplateComponents(options) {
74
73
  yield `let __VLS_components!: __VLS_LocalComponents & __VLS_GlobalComponents${utils_1.endOfLine}`;
75
74
  }
76
75
  function* generateTemplateDirectives(options) {
77
- const types = [];
76
+ const types = [`typeof __VLS_ctx`];
78
77
  if (options.sfc.script && options.scriptRanges?.exportDefault?.directivesOption) {
79
78
  const { directivesOption } = options.scriptRanges.exportDefault;
80
79
  yield `const __VLS_directivesOption = `;
@@ -85,9 +84,8 @@ function* generateTemplateDirectives(options) {
85
84
  codeFeatures_1.codeFeatures.navigation,
86
85
  ];
87
86
  yield utils_1.endOfLine;
88
- types.push(`typeof __VLS_directivesOption`);
87
+ types.push(`__VLS_ResolveDirectives<typeof __VLS_directivesOption>`);
89
88
  }
90
- types.push(`typeof __VLS_ctx`);
91
89
  yield `type __VLS_LocalDirectives =`;
92
90
  for (const type of types) {
93
91
  yield ` & `;
@@ -1,6 +1,6 @@
1
- import type * as CompilerDOM from '@vue/compiler-dom';
1
+ import * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { Code, VueCodeInformation } from '../../types';
3
- import { InlayHintInfo } from '../inlayHints';
3
+ import type { InlayHintInfo } from '../inlayHints';
4
4
  import type { TemplateCodegenOptions } from './index';
5
5
  export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenContext>;
6
6
  /**
@@ -101,6 +101,17 @@ export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenCont
101
101
  * and additionally how we use that to determine whether to propagate diagnostics back upward.
102
102
  */
103
103
  export declare function createTemplateCodegenContext(options: Pick<TemplateCodegenOptions, 'scriptSetupBindingNames'>): {
104
+ readonly currentInfo: {
105
+ ignoreError?: boolean;
106
+ expectError?: {
107
+ token: number;
108
+ node: CompilerDOM.CommentNode;
109
+ };
110
+ generic?: {
111
+ content: string;
112
+ offset: number;
113
+ };
114
+ };
104
115
  codeFeatures: {
105
116
  all: VueCodeInformation;
106
117
  none: VueCodeInformation;
@@ -118,8 +129,10 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
118
129
  withoutHighlightAndNavigation: VueCodeInformation;
119
130
  withoutHighlightAndCompletion: VueCodeInformation;
120
131
  withoutHighlightAndCompletionAndNavigation: VueCodeInformation;
132
+ withoutSemantic: VueCodeInformation;
121
133
  };
122
134
  resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation;
135
+ inVFor: boolean;
123
136
  slots: {
124
137
  name: string;
125
138
  offset?: number;
@@ -133,10 +146,6 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
133
146
  }[];
134
147
  dollarVars: Set<string>;
135
148
  accessExternalVariables: Map<string, Set<number>>;
136
- lastGenericComment: {
137
- content: string;
138
- offset: number;
139
- } | undefined;
140
149
  blockConditions: string[];
141
150
  scopedClasses: {
142
151
  source: string;
@@ -150,23 +159,24 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
150
159
  templateRefs: Map<string, {
151
160
  typeExp: string;
152
161
  offset: number;
153
- }>;
162
+ }[]>;
154
163
  currentComponent: {
155
164
  ctxVar: string;
165
+ childTypes: string[];
156
166
  used: boolean;
157
167
  } | undefined;
158
168
  singleRootElTypes: string[];
159
169
  singleRootNodes: Set<CompilerDOM.ElementNode | null>;
170
+ addTemplateRef(name: string, typeExp: string, offset: number): void;
160
171
  accessExternalVariable(name: string, offset?: number): void;
161
- hasLocalVariable: (name: string) => boolean;
162
- addLocalVariable: (name: string) => void;
163
- removeLocalVariable: (name: string) => void;
164
- getInternalVariable: () => string;
165
- getHoistVariable: (originalVar: string) => string;
166
- generateHoistVariables: () => Generator<string, void, unknown>;
167
- generateConditionGuards: () => Generator<string, void, unknown>;
168
- ignoreError: () => Generator<Code>;
169
- expectError: (prevNode: CompilerDOM.CommentNode) => Generator<Code>;
170
- resetDirectiveComments: (endStr: string) => Generator<Code>;
171
- generateAutoImportCompletion: () => Generator<Code>;
172
+ hasLocalVariable(name: string): boolean;
173
+ addLocalVariable(name: string): void;
174
+ removeLocalVariable(name: string): void;
175
+ getInternalVariable(): string;
176
+ getHoistVariable(originalVar: string): string;
177
+ generateHoistVariables(): Generator<string, void, unknown>;
178
+ generateConditionGuards(): Generator<string, void, unknown>;
179
+ generateAutoImportCompletion(): Generator<Code>;
180
+ enter(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode | CompilerDOM.SimpleExpressionNode): boolean;
181
+ exit(): Generator<Code>;
172
182
  };