@vue/language-core 1.7.1 → 1.7.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.
@@ -7,7 +7,7 @@ import type { ScriptRanges } from '../parsers/scriptRanges';
7
7
  import type { ScriptSetupRanges } from '../parsers/scriptSetupRanges';
8
8
  import { Sfc } from '../types';
9
9
  import type { VueCompilerOptions } from '../types';
10
- export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), fileName: string, _sfc: Sfc, lang: string, scriptRanges: ScriptRanges | undefined, scriptSetupRanges: ScriptSetupRanges | undefined, htmlGen: ReturnType<typeof templateGen['generate']> | undefined, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, sharedTypesImport: string, codegenStack: boolean): {
10
+ export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), fileName: string, _sfc: Sfc, lang: string, scriptRanges: ScriptRanges | undefined, scriptSetupRanges: ScriptSetupRanges | undefined, htmlGen: ReturnType<typeof templateGen['generate']> | undefined, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codegenStack: boolean): {
11
11
  codes: Segment<FileRangeCapabilities>[];
12
12
  codeStacks: SourceMaps.StackNode[];
13
13
  mirrorBehaviorMappings: SourceMaps.Mapping<[MirrorBehaviorCapabilities, MirrorBehaviorCapabilities]>[];
@@ -9,7 +9,7 @@ const shared_2 = require("../utils/shared");
9
9
  const transform_1 = require("../utils/transform");
10
10
  const sharedTypes = require("../utils/directorySharedTypes");
11
11
  const muggle = require("muggle-string");
12
- function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htmlGen, compilerOptions, vueCompilerOptions, sharedTypesImport, codegenStack) {
12
+ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htmlGen, compilerOptions, vueCompilerOptions, codegenStack) {
13
13
  const [codes, codeStacks] = codegenStack ? muggle.track([]) : [[], []];
14
14
  const mirrorBehaviorMappings = [];
15
15
  //#region monkey fix: https://github.com/vuejs/language-tools/pull/2113
@@ -528,13 +528,13 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
528
528
  // fill $props
529
529
  if (scriptSetupRanges.propsTypeArg) {
530
530
  // NOTE: defineProps is inaccurate for $props
531
- codes.push(`$props: (await import('${sharedTypesImport}')).makeOptional(defineProps<`);
531
+ codes.push(`$props: __VLS_makeOptional(defineProps<`);
532
532
  addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.propsTypeArg.start, scriptSetupRanges.propsTypeArg.end);
533
533
  codes.push(`>()),\n`);
534
534
  }
535
535
  else if (scriptSetupRanges.propsRuntimeArg) {
536
536
  // NOTE: defineProps is inaccurate for $props
537
- codes.push(`$props: (await import('${sharedTypesImport}')).makeOptional(defineProps(`);
537
+ codes.push(`$props: __VLS_makeOptional(defineProps(`);
538
538
  addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.propsRuntimeArg.start, scriptSetupRanges.propsRuntimeArg.end);
539
539
  codes.push(`)),\n`);
540
540
  }
@@ -714,15 +714,15 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
714
714
  const useGlobalThisTypeInCtx = fileName.endsWith('.html');
715
715
  codes.push(`let __VLS_ctx!: ${useGlobalThisTypeInCtx ? 'typeof globalThis &' : ''}`);
716
716
  if (sfc.scriptSetup) {
717
- codes.push(`InstanceType<import('${sharedTypesImport}').PickNotAny<typeof __VLS_publicComponent, new () => {}>> & `);
717
+ codes.push(`InstanceType<__VLS_PickNotAny<typeof __VLS_publicComponent, new () => {}>> & `);
718
718
  }
719
- codes.push(`InstanceType<import('${sharedTypesImport}').PickNotAny<typeof __VLS_internalComponent, new () => {}>> & {\n`);
719
+ codes.push(`InstanceType<__VLS_PickNotAny<typeof __VLS_internalComponent, new () => {}>> & {\n`);
720
720
  /* CSS Module */
721
721
  for (let i = 0; i < _sfc.styles.length; i++) {
722
722
  const style = _sfc.styles[i];
723
723
  if (!style.module)
724
724
  continue;
725
- codes.push(`${style.module}: Record<string, string> & import('${sharedTypesImport}').Prettify<{}`);
725
+ codes.push(`${style.module}: Record<string, string> & __VLS_Prettify<{}`);
726
726
  for (const className of style.classNames) {
727
727
  generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'string', false);
728
728
  }
@@ -732,8 +732,8 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
732
732
  /* Components */
733
733
  codes.push('/* Components */\n');
734
734
  codes.push(`let __VLS_localComponents!: NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}> & typeof __VLS_componentsOption & typeof __VLS_ctx;\n`);
735
- codes.push(`let __VLS_otherComponents!: typeof __VLS_localComponents & import('${sharedTypesImport}').GlobalComponents;\n`);
736
- codes.push(`let __VLS_own!: import('${sharedTypesImport}').SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)(vueCompilerOptions.target)}: typeof __VLS_slots })>;\n`);
735
+ codes.push(`let __VLS_otherComponents!: typeof __VLS_localComponents & __VLS_GlobalComponents;\n`);
736
+ codes.push(`let __VLS_own!: __VLS_SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)(vueCompilerOptions.target)}: typeof __VLS_slots })>;\n`);
737
737
  codes.push(`let __VLS_components!: typeof __VLS_otherComponents & Omit<typeof __VLS_own, keyof typeof __VLS_otherComponents>;\n`);
738
738
  /* Style Scoped */
739
739
  codes.push('/* Style Scoped */\n');
@@ -5,7 +5,7 @@ import type * as ts from 'typescript/lib/tsserverlibrary';
5
5
  import { Sfc, VueCompilerOptions } from '../types';
6
6
  import * as muggle from 'muggle-string';
7
7
  type Code = Segment<FileRangeCapabilities>;
8
- export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, sourceTemplate: string, sourceLang: string, sfc: Sfc, hasScriptSetupSlots: boolean, sharedTypesImport: string, codegenStack: boolean): {
8
+ export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, sourceTemplate: string, sourceLang: string, sfc: Sfc, hasScriptSetupSlots: boolean, codegenStack: boolean): {
9
9
  codes: Code[];
10
10
  codeStacks: muggle.StackNode[];
11
11
  formatCodes: Code[];
@@ -57,7 +57,7 @@ const transformContext = {
57
57
  },
58
58
  expressionPlugins: ['typescript'],
59
59
  };
60
- function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourceLang, sfc, hasScriptSetupSlots, sharedTypesImport, codegenStack) {
60
+ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourceLang, sfc, hasScriptSetupSlots, codegenStack) {
61
61
  const [codes, codeStacks] = codegenStack ? muggle.track([]) : [[], []];
62
62
  const [formatCodes, formatCodeStacks] = codegenStack ? muggle.track([]) : [[], []];
63
63
  const [cssCodes, cssCodeStacks] = codegenStack ? muggle.track([]) : [[], []];
@@ -147,7 +147,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
147
147
  if (isNamespacedTag)
148
148
  continue;
149
149
  const varName = validTsVar.test(tagName) ? tagName : (0, shared_1.capitalize)((0, shared_1.camelize)(tagName.replace(/:/g, '-')));
150
- codes.push(`& import('${sharedTypesImport}').WithComponent<'${varName}', typeof __VLS_components, `,
150
+ codes.push(`& __VLS_WithComponent<'${varName}', typeof __VLS_components, `,
151
151
  // order is important: https://github.com/vuejs/language-tools/issues/2010
152
152
  `"${(0, shared_1.capitalize)((0, shared_1.camelize)(tagName))}", `, `"${(0, shared_1.camelize)(tagName)}", `, `"${tagName}"`, '>\n');
153
153
  data[tagName] = varName;
@@ -353,7 +353,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
353
353
  codes.push([leftExpressionText, 'template', leftExpressionRange.start, capabilitiesPresets.all]);
354
354
  formatCodes.push(...createFormatCode(leftExpressionText, leftExpressionRange.start, formatBrackets.normal));
355
355
  }
356
- codes.push(`] of (await import('${sharedTypesImport}')).getVForSourceType`);
356
+ codes.push(`] of __VLS_getVForSourceType`);
357
357
  if (source.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
358
358
  codes.push('(', ...createInterpolationCode(source.content, source.loc, source.loc.start.offset, capabilitiesPresets.all, '(', ')'), '!)', // #3102
359
359
  ') {\n');
@@ -414,7 +414,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
414
414
  else {
415
415
  codes.push(`const ${var_originalComponent} = {} as any;\n`);
416
416
  }
417
- codes.push(`const ${var_functionalComponent} = (await import('${sharedTypesImport}')).asFunctionalComponent(`, `${var_originalComponent}, `, `new ${var_originalComponent}({`, ...createPropsCode(node, props, 'extraReferences'), '}));\n');
417
+ codes.push(`const ${var_functionalComponent} = __VLS_asFunctionalComponent(`, `${var_originalComponent}, `, `new ${var_originalComponent}({`, ...createPropsCode(node, props, 'extraReferences'), '}));\n');
418
418
  for (const offset of tagOffsets) {
419
419
  if (isNamespacedTag) {
420
420
  continue;
@@ -445,10 +445,10 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
445
445
  // diagnostic end
446
446
  tagOffsets.length ? ['', 'template', tagOffsets[0] + tag.length, capabilitiesPresets.diagnosticOnly]
447
447
  : dynamicTagExp ? ['', 'template', startTagOffset + tag.length, capabilitiesPresets.diagnosticOnly]
448
- : '', `, ...(await import('${sharedTypesImport}')).functionalComponentArgsRest(${var_functionalComponent}));\n`);
448
+ : '', `, ...__VLS_functionalComponentArgsRest(${var_functionalComponent}));\n`);
449
449
  if (tag !== 'template' && tag !== 'slot') {
450
450
  componentCtxVar = `__VLS_${elementIndex++}`;
451
- codes.push(`const ${componentCtxVar} = (await import('${sharedTypesImport}')).pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance})!;\n`);
451
+ codes.push(`const ${componentCtxVar} = __VLS_pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance})!;\n`);
452
452
  parentEl = node;
453
453
  }
454
454
  //#region
@@ -466,7 +466,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
466
466
  let originalConditionsNum = blockConditions.length;
467
467
  if (vScope?.type === 7 /* CompilerDOM.NodeTypes.DIRECTIVE */ && vScope.exp) {
468
468
  const scopeVar = `__VLS_${elementIndex++}`;
469
- const condition = `(await import('${sharedTypesImport}')).withScope(__VLS_ctx, ${scopeVar})`;
469
+ const condition = `__VLS_withScope(__VLS_ctx, ${scopeVar})`;
470
470
  codes.push(`const ${scopeVar} = `);
471
471
  codes.push([
472
472
  vScope.exp.loc.source,
@@ -511,7 +511,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
511
511
  'template',
512
512
  slotDir.exp.loc.start.offset,
513
513
  capabilitiesPresets.all,
514
- ], `] = (await import('${sharedTypesImport}')).getSlotParams(`);
514
+ ], `] = __VLS_getSlotParams(`);
515
515
  }
516
516
  else {
517
517
  codes.push('const ', [
@@ -519,10 +519,10 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
519
519
  'template',
520
520
  slotDir.exp.loc.start.offset,
521
521
  capabilitiesPresets.all,
522
- ], ` = (await import('${sharedTypesImport}')).getSlotParam(`);
522
+ ], ` = __VLS_getSlotParam(`);
523
523
  }
524
524
  }
525
- codes.push(['', 'template', (slotDir.arg ?? slotDir).loc.start.offset, capabilitiesPresets.diagnosticOnly], `${componentCtxVar}.slots!`, ...((slotDir?.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */ && slotDir.arg.content)
525
+ codes.push(['', 'template', (slotDir.arg ?? slotDir).loc.start.offset, capabilitiesPresets.diagnosticOnly], `(${componentCtxVar}.slots!)`, ...((slotDir?.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */ && slotDir.arg.content)
526
526
  ? createPropertyAccessCode([
527
527
  slotDir.arg.loc.source,
528
528
  'template',
@@ -576,7 +576,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
576
576
  && prop.name === 'on'
577
577
  && prop.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
578
578
  const eventVar = `__VLS_${elementIndex++}`;
579
- codes.push(`let ${eventVar} = { '${prop.arg.loc.source}': `, `(await import('${sharedTypesImport}')).pickEvent(${componentCtxVar}.emit!, '${prop.arg.loc.source}' as const, (await import('${sharedTypesImport}')).componentProps(${componentVar}, ${componentInstanceVar})`, ...createPropertyAccessCode([
579
+ codes.push(`let ${eventVar} = { '${prop.arg.loc.source}': `, `__VLS_pickEvent(${componentCtxVar}.emit!, '${prop.arg.loc.source}' as const, __VLS_componentProps(${componentVar}, ${componentInstanceVar})`, ...createPropertyAccessCode([
580
580
  (0, shared_1.camelize)('on-' + prop.arg.loc.source),
581
581
  'template',
582
582
  [prop.arg.loc.start.offset, prop.arg.loc.end.offset],
@@ -974,7 +974,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
974
974
  'template',
975
975
  prop.loc.start.offset,
976
976
  capabilitiesPresets.diagnosticOnly,
977
- ], `(await import('${sharedTypesImport}')).directiveFunction(__VLS_ctx.`, [
977
+ ], `__VLS_directiveFunction(__VLS_ctx.`, [
978
978
  (0, shared_1.camelize)('v-' + prop.name),
979
979
  'template',
980
980
  [prop.loc.start.offset, prop.loc.start.offset + 'v-'.length + prop.name.length],
@@ -32,10 +32,9 @@ function createLanguage(compilerOptions = {}, vueCompilerOptions = (0, ts_1.reso
32
32
  return host.fileExists(fileName);
33
33
  },
34
34
  getScriptFileNames() {
35
- const fileNames = host.getScriptFileNames();
36
35
  return [
37
- ...getSharedTypesFiles(fileNames),
38
- ...fileNames,
36
+ path_1.posix.join(host.getCurrentDirectory(), sharedTypes.baseName),
37
+ ...host.getScriptFileNames(),
39
38
  ];
40
39
  },
41
40
  getScriptVersion(fileName) {
@@ -56,11 +55,6 @@ function createLanguage(compilerOptions = {}, vueCompilerOptions = (0, ts_1.reso
56
55
  },
57
56
  };
58
57
  return languageModule;
59
- function getSharedTypesFiles(fileNames) {
60
- const moduleFiles = fileNames.filter(fileName => vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext)));
61
- const moduleFileDirs = [...new Set(moduleFiles.map(path_1.posix.dirname))];
62
- return moduleFileDirs.map(dir => path_1.posix.join(dir, sharedTypes.baseName));
63
- }
64
58
  }
65
59
  exports.createLanguage = createLanguage;
66
60
  function createLanguages(compilerOptions = {}, vueCompilerOptions = (0, ts_1.resolveVueCompilerOptions)({}), ts = require('typescript'), codegenStack = false) {
@@ -6,12 +6,10 @@ const templateGen = require("../generators/template");
6
6
  const scriptRanges_1 = require("../parsers/scriptRanges");
7
7
  const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
8
8
  const language_core_1 = require("@volar/language-core");
9
- const sharedTypes = require("../utils/directorySharedTypes");
10
9
  const muggle = require("muggle-string");
11
10
  const plugin = ({ modules, vueCompilerOptions, compilerOptions, codegenStack }) => {
12
11
  const ts = modules.typescript;
13
12
  const instances = new WeakMap();
14
- const sharedTypesImport = sharedTypes.getImportName(compilerOptions);
15
13
  return {
16
14
  version: 1,
17
15
  getEmbeddedFileNames(fileName, sfc) {
@@ -108,12 +106,12 @@ const plugin = ({ modules, vueCompilerOptions, compilerOptions, codegenStack })
108
106
  const htmlGen = (0, reactivity_1.computed)(() => {
109
107
  if (!_sfc.templateAst)
110
108
  return;
111
- return templateGen.generate(ts, compilerOptions, vueCompilerOptions, _sfc.template?.content ?? '', _sfc.template?.lang ?? 'html', _sfc, hasScriptSetupSlots.value, sharedTypesImport, codegenStack);
109
+ return templateGen.generate(ts, compilerOptions, vueCompilerOptions, _sfc.template?.content ?? '', _sfc.template?.lang ?? 'html', _sfc, hasScriptSetupSlots.value, codegenStack);
112
110
  });
113
111
  const hasScriptSetupSlots = (0, reactivity_1.shallowRef)(false); // remove when https://github.com/vuejs/core/pull/5912 merged
114
112
  const tsxGen = (0, reactivity_1.computed)(() => {
115
113
  hasScriptSetupSlots.value = !!scriptSetupRanges.value?.slotsTypeArg;
116
- return (0, script_1.generate)(ts, fileName, _sfc, lang.value, scriptRanges.value, scriptSetupRanges.value, htmlGen.value, compilerOptions, vueCompilerOptions, sharedTypesImport, codegenStack);
114
+ return (0, script_1.generate)(ts, fileName, _sfc, lang.value, scriptRanges.value, scriptSetupRanges.value, htmlGen.value, compilerOptions, vueCompilerOptions, codegenStack);
117
115
  });
118
116
  return {
119
117
  lang,
@@ -1,6 +1,4 @@
1
1
  import { VueCompilerOptions } from '../types';
2
- import type * as ts from 'typescript/lib/tsserverlibrary';
3
2
  export declare const baseName = "__VLS_types.d.ts";
4
- export declare function getImportName(compilerOptions: ts.CompilerOptions): "./__VLS_types" | "./__VLS_types.js";
5
3
  export declare function getTypesCode(vueCompilerOptions: VueCompilerOptions): string;
6
4
  export declare function genConstructorOverloads(name?: string, nums?: number): string;
@@ -1,42 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genConstructorOverloads = exports.getTypesCode = exports.getImportName = exports.baseName = void 0;
3
+ exports.genConstructorOverloads = exports.getTypesCode = exports.baseName = void 0;
4
4
  const shared_1 = require("./shared");
5
5
  exports.baseName = '__VLS_types.d.ts';
6
- function getImportName(compilerOptions) {
7
- if (!compilerOptions.module || compilerOptions.module === 1) {
8
- return './__VLS_types';
9
- }
10
- return './__VLS_types.js';
11
- }
12
- exports.getImportName = getImportName;
13
- ;
14
6
  function getTypesCode(vueCompilerOptions) {
15
7
  return `
16
8
  // @ts-nocheck
17
- import type {
18
- ObjectDirective,
19
- FunctionDirective,
20
- VNode,
21
- } from '${vueCompilerOptions.lib}';
22
9
 
23
- export type IntrinsicElements = PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, PickNotAny<JSX.IntrinsicElements, Record<string, any>>>;
24
- export type Element = PickNotAny<import('vue/jsx-runtime').JSX.Element, JSX.Element>;
10
+ type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<JSX.IntrinsicElements, Record<string, any>>>;
11
+ type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, JSX.Element>;
25
12
 
26
- type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
27
- export type PickNotAny<A, B> = IsAny<A> extends true ? B : A;
13
+ type __VLS_IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
14
+ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
28
15
 
29
- export type Prettify<T> = {
16
+ type __VLS_Prettify<T> = {
30
17
  [K in keyof T]: T[K];
31
18
  } & {};
32
19
 
33
- export type GlobalComponents =
20
+ type __VLS_GlobalComponents =
34
21
  // @ts-ignore
35
- PickNotAny<import('vue').GlobalComponents, {}>
22
+ __VLS_PickNotAny<import('vue').GlobalComponents, {}>
36
23
  // @ts-ignore
37
- & PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>
24
+ & __VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>
38
25
  // @ts-ignore
39
- & PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>
26
+ & __VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>
40
27
  & Pick<typeof import('${vueCompilerOptions.lib}'),
41
28
  // @ts-ignore
42
29
  'Transition'
@@ -47,44 +34,44 @@ export type GlobalComponents =
47
34
  >;
48
35
 
49
36
  // v-for
50
- export declare function getVForSourceType(source: number): [number, number, number][];
51
- export declare function getVForSourceType(source: string): [string, number, number][];
52
- export declare function getVForSourceType<T extends any[]>(source: T): [
37
+ declare function __VLS_getVForSourceType(source: number): [number, number, number][];
38
+ declare function __VLS_getVForSourceType(source: string): [string, number, number][];
39
+ declare function __VLS_getVForSourceType<T extends any[]>(source: T): [
53
40
  T[number], // item
54
41
  number, // key
55
42
  number, // index
56
43
  ][];
57
- export declare function getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
44
+ declare function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
58
45
  T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never, // item
59
46
  number, // key
60
47
  undefined, // index
61
48
  ][];
62
- export declare function getVForSourceType<T>(source: T): [
49
+ declare function __VLS_getVForSourceType<T>(source: T): [
63
50
  T[keyof T], // item
64
51
  keyof T, // key
65
52
  number, // index
66
53
  ][];
67
54
 
68
- export declare function getSlotParams<T>(slot: T): Parameters<PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
69
- export declare function getSlotParam<T>(slot: T): Parameters<PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
70
- export declare function directiveFunction<T>(dir: T):
71
- T extends ObjectDirective<infer E, infer V> | FunctionDirective<infer E, infer V> ? (el: E, value: V) => void
55
+ declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
56
+ declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
57
+ declare function __VLS_directiveFunction<T>(dir: T):
58
+ T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (el: E, value: V) => void
72
59
  : T;
73
- export declare function withScope<T, K>(ctx: T, scope: K): ctx is T & K;
74
- export declare function makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
60
+ declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
61
+ declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
75
62
 
76
- export type SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
77
- export type WithComponent<N0 extends string, Components, N1 extends string, N2 extends string, N3 extends string> =
78
- IsAny<IntrinsicElements[N0]> extends true ? (
63
+ type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
64
+ type __VLS_WithComponent<N0 extends string, Components, N1 extends string, N2 extends string, N3 extends string> =
65
+ __VLS_IsAny<__VLS_IntrinsicElements[N0]> extends true ? (
79
66
  N1 extends keyof Components ? N1 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N1] } :
80
67
  N2 extends keyof Components ? N2 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N2] } :
81
68
  N3 extends keyof Components ? N3 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N3] } :
82
69
  ${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: any }'}
83
- ) : Pick<IntrinsicElements, N0>;
70
+ ) : Pick<__VLS_IntrinsicElements, N0>;
84
71
 
85
- export type FillingEventArg_ParametersLength<E extends (...args: any) => any> = IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
86
- export type FillingEventArg<E> = E extends (...args: any) => any ? FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
87
- export type EmitEvent<F, E> =
72
+ type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
73
+ type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
74
+ type __VLS_EmitEvent<F, E> =
88
75
  F extends {
89
76
  (event: E, ...payload: infer P): any
90
77
  } ? (...payload: P) => void
@@ -104,7 +91,7 @@ export type EmitEvent<F, E> =
104
91
  (...args: any): any
105
92
  } ? (...payload: P) => void
106
93
  : unknown | '[Type Warning] Volar could not infer $emit event more than 4 overloads without DefineComponent. see https://github.com/vuejs/language-tools/issues/60';
107
- export declare function asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
94
+ declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
108
95
  T extends new (...args: any) => any
109
96
  ? (props: (K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: {
110
97
  attrs?: any,
@@ -113,22 +100,22 @@ export declare function asFunctionalComponent<T, K = T extends new (...args: any
113
100
  }) => JSX.Element & { __ctx?: typeof ctx & { props?: typeof props; expose?(exposed: K): void; } }
114
101
  : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
115
102
  : T extends (...args: any) => any ? T
116
- : (_: T extends VNode | VNode[] | string ? {}: T & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: unknown, expose?: unknown, slots?: unknown, emit?: unknown, props?: T & Record<string, unknown> } }; // IntrinsicElement
117
- declare function functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
118
- export declare function pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): FillingEventArg<
119
- PickNotAny<
120
- AsFunctionOrAny<E>,
121
- AsFunctionOrAny<EmitEvent<Emit, K>>
103
+ : (_: T extends import('${vueCompilerOptions.lib}').VNode | import('${vueCompilerOptions.lib}').VNode[] | string ? {}: T & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: unknown, expose?: unknown, slots?: unknown, emit?: unknown, props?: T & Record<string, unknown> } }; // IntrinsicElement
104
+ declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
105
+ declare function __VLS_pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): __VLS_FillingEventArg<
106
+ __VLS_PickNotAny<
107
+ __VLS_AsFunctionOrAny<E>,
108
+ __VLS_AsFunctionOrAny<__VLS_EmitEvent<Emit, K>>
122
109
  >
123
110
  >;
124
- export declare function pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): PickNotAny<
111
+ declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<
125
112
  K extends { __ctx?: infer Ctx } ? Ctx : any,
126
113
  T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
127
114
  >;
128
- type AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
115
+ type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
129
116
 
130
- export declare function componentProps<T, K>(comp: T, fnReturn: K):
131
- PickNotAny<K, {}> extends { __ctx: { props: infer P } } ? NonNullable<P>
117
+ declare function __VLS_componentProps<T, K>(comp: T, fnReturn: K):
118
+ __VLS_PickNotAny<K, {}> extends { __ctx: { props: infer P } } ? NonNullable<P>
132
119
  : T extends (props: infer P, ...args: any) => any ? NonNullable<P> :
133
120
  {};
134
121
  `.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "1.7.1",
3
+ "version": "1.7.4",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,18 +13,18 @@
13
13
  "directory": "packages/vue-language-core"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "1.6.1",
17
- "@volar/source-map": "1.6.1",
18
- "@vue/compiler-dom": "^3.3.0-beta.3",
19
- "@vue/reactivity": "^3.3.0-beta.3",
20
- "@vue/shared": "^3.3.0-beta.3",
16
+ "@volar/language-core": "1.6.5",
17
+ "@volar/source-map": "1.6.5",
18
+ "@vue/compiler-dom": "^3.3.0",
19
+ "@vue/reactivity": "^3.3.0",
20
+ "@vue/shared": "^3.3.0",
21
21
  "minimatch": "^9.0.0",
22
22
  "muggle-string": "^0.3.1",
23
23
  "vue-template-compiler": "^2.7.14"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/minimatch": "^5.1.2",
27
- "@vue/compiler-sfc": "^3.3.0-beta.3"
27
+ "@vue/compiler-sfc": "^3.3.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "typescript": "*"
@@ -34,5 +34,5 @@
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "gitHead": "8555895e2018cb871cceb19f0ff073fcf322d8e5"
37
+ "gitHead": "30fed93ac21d4d4fbf2351b85ebe65acb1216496"
38
38
  }