@vue/language-core 2.1.0 → 2.1.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.
@@ -1 +1 @@
1
- export declare function generateGlobalTypes(lib: string, target: number, strictTemplates: boolean): string;
1
+ export declare function generateGlobalTypes(mode: 'global' | 'local', lib: string, target: number, strictTemplates: boolean): string;
@@ -2,13 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateGlobalTypes = generateGlobalTypes;
4
4
  const shared_1 = require("../utils/shared");
5
- function generateGlobalTypes(lib, target, strictTemplates) {
5
+ const common_1 = require("./common");
6
+ function generateGlobalTypes(mode, lib, target, strictTemplates) {
6
7
  const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${strictTemplates ? '' : ' & Record<string, unknown>'}`;
7
- return `
8
- const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents };
9
-
10
- declare const __VLS_intrinsicElements: __VLS_IntrinsicElements;
11
- declare const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any };
8
+ let str = '';
9
+ let globalComponentsType;
10
+ if (mode === 'global') {
11
+ str += `// @ts-nocheck${common_1.newLine}`;
12
+ str += `export {}${common_1.endOfLine}`;
13
+ str += `declare module '${lib}' {${common_1.newLine}`;
14
+ str += ` export interface GlobalComponents { }${common_1.newLine}`;
15
+ str += `}${common_1.newLine}`;
16
+ str += `declare global {${common_1.newLine}`;
17
+ globalComponentsType = `import('${lib}').GlobalComponents`;
18
+ }
19
+ else {
20
+ str += `const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents }${common_1.endOfLine}`;
21
+ globalComponentsType = `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents`;
22
+ }
23
+ str += `
24
+ const __VLS_intrinsicElements: __VLS_IntrinsicElements;
25
+ const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any };
12
26
 
13
27
  type __VLS_IntrinsicElements = ${(target >= 3.3
14
28
  ? `import('${lib}/jsx-runtime').JSX.IntrinsicElements;`
@@ -17,8 +31,8 @@ type __VLS_Element = ${(target >= 3.3
17
31
  ? `import('${lib}/jsx-runtime').JSX.Element;`
18
32
  : `globalThis.JSX.Element;`)}
19
33
  type __VLS_GlobalComponents = ${(target >= 3.5
20
- ? `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents;`
21
- : `(void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`)}
34
+ ? globalComponentsType
35
+ : `(${globalComponentsType}) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`)}
22
36
  type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
23
37
  type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
24
38
  type __VLS_unknownDirective = (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
@@ -66,40 +80,40 @@ type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
66
80
  >;
67
81
  type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
68
82
 
69
- declare function __VLS_getVForSourceType(source: number): [number, number, number][];
70
- declare function __VLS_getVForSourceType(source: string): [string, number, number][];
71
- declare function __VLS_getVForSourceType<T extends any[]>(source: T): [
83
+ function __VLS_getVForSourceType(source: number): [number, number, number][];
84
+ function __VLS_getVForSourceType(source: string): [string, number, number][];
85
+ function __VLS_getVForSourceType<T extends any[]>(source: T): [
72
86
  item: T[number],
73
87
  key: number,
74
88
  index: number,
75
89
  ][];
76
- declare function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
90
+ function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
77
91
  item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never,
78
92
  key: number,
79
93
  index: undefined,
80
94
  ][];
81
95
  // #3845
82
- declare function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
96
+ function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
83
97
  item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never),
84
98
  key: number,
85
99
  index: undefined,
86
100
  ][];
87
- declare function __VLS_getVForSourceType<T>(source: T): [
101
+ function __VLS_getVForSourceType<T>(source: T): [
88
102
  item: T[keyof T],
89
103
  key: keyof T,
90
104
  index: number,
91
105
  ][];
92
106
  // @ts-ignore
93
- declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
107
+ function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
94
108
  // @ts-ignore
95
- declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
96
- declare function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any
109
+ function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
110
+ function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any
97
111
  ? T | __VLS_unknownDirective
98
112
  : NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
99
- declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
100
- declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
101
- declare function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
102
- declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
113
+ function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
114
+ function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
115
+ function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
116
+ function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
103
117
  T extends new (...args: any) => any
104
118
  ? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
105
119
  attrs?: any,
@@ -109,15 +123,19 @@ declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any)
109
123
  : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
110
124
  : T extends (...args: any) => any ? T
111
125
  : (_: {}${strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${strictTemplates ? '' : ' & Record<string, unknown>'} } };
112
- declare function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
113
- declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
114
- declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny<
126
+ function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
127
+ function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
128
+ function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny<
115
129
  '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
116
130
  , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
117
131
  >>;
118
- declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
119
- declare function __VLS_tryAsConstant<const T>(t: T): T;
132
+ function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
133
+ function __VLS_tryAsConstant<const T>(t: T): T;
120
134
  `;
135
+ if (mode === 'global') {
136
+ str += `}${common_1.newLine}`;
137
+ }
138
+ return str;
121
139
  }
122
140
  ;
123
141
  //# sourceMappingURL=globalTypes.js.map
@@ -10,5 +10,4 @@ export declare function getLocalTypesGenerator(compilerOptions: ts.CompilerOptio
10
10
  readonly PropsChildren: string;
11
11
  readonly TypePropsToOption: string;
12
12
  readonly OmitIndexSignature: string;
13
- readonly PickRefsExpose: string;
14
13
  };
@@ -58,15 +58,6 @@ type __VLS_TypePropsToOption<T> = {
58
58
  };
59
59
  `.trimStart());
60
60
  const OmitIndexSignature = defineHelper(`__VLS_OmitIndexSignature`, () => `type __VLS_OmitIndexSignature<T> = { [K in keyof T as {} extends Record<K, unknown> ? never : K]: T[K]; }${common_1.endOfLine}`);
61
- const PickRefsExpose = defineHelper(`__VLS_PickRefsExpose`, () => `
62
- type __VLS_PickRefsExpose<T> = T extends object
63
- ? { [K in keyof T]: (T[K] extends any[]
64
- ? Parameters<T[K][0]['expose']>[0][]
65
- : T[K] extends { expose?: (exposed: infer E) => void }
66
- ? E
67
- : T[K]) | null }
68
- : never;
69
- `.trimStart());
70
61
  const helpers = {
71
62
  [PrettifyLocal.name]: PrettifyLocal,
72
63
  [OmitKeepDiscriminatedUnion.name]: OmitKeepDiscriminatedUnion,
@@ -75,7 +66,6 @@ type __VLS_PickRefsExpose<T> = T extends object
75
66
  [PropsChildren.name]: PropsChildren,
76
67
  [TypePropsToOption.name]: TypePropsToOption,
77
68
  [OmitIndexSignature.name]: OmitIndexSignature,
78
- [PickRefsExpose.name]: PickRefsExpose,
79
69
  };
80
70
  used.clear();
81
71
  return {
@@ -90,7 +80,6 @@ type __VLS_PickRefsExpose<T> = T extends object
90
80
  get PropsChildren() { return PropsChildren.name; },
91
81
  get TypePropsToOption() { return TypePropsToOption.name; },
92
82
  get OmitIndexSignature() { return OmitIndexSignature.name; },
93
- get PickRefsExpose() { return PickRefsExpose.name; },
94
83
  };
95
84
  function* generate(names) {
96
85
  const generated = new Set();
@@ -23,7 +23,6 @@ export declare function createScriptCodegenContext(options: ScriptCodegenOptions
23
23
  readonly PropsChildren: string;
24
24
  readonly TypePropsToOption: string;
25
25
  readonly OmitIndexSignature: string;
26
- readonly PickRefsExpose: string;
27
26
  };
28
27
  inlayHints: InlayHintInfo[];
29
28
  };
@@ -0,0 +1,2 @@
1
+ import type { VueCompilerOptions } from '../../types';
2
+ export declare function generateGlobalTypes(vueCompilerOptions: VueCompilerOptions): string;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateGlobalTypes = generateGlobalTypes;
4
+ const shared_1 = require("../../utils/shared");
5
+ function generateGlobalTypes(vueCompilerOptions) {
6
+ const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}`;
7
+ return `export const __VLS_globalTypesStart = {};
8
+ declare module '${vueCompilerOptions.lib}' {
9
+ interface GlobalComponents {}
10
+ }
11
+ declare global {
12
+ type __VLS_IntrinsicElements = ${vueCompilerOptions.target >= 3.3
13
+ ? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements;`
14
+ : `globalThis.JSX.IntrinsicElements;`}
15
+ type __VLS_Element = ${vueCompilerOptions.target >= 3.3
16
+ ? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element;`
17
+ : `globalThis.JSX.Element;`}
18
+ type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5
19
+ ? `import('${vueCompilerOptions.lib}').GlobalComponents;`
20
+ : `import('${vueCompilerOptions.lib}').GlobalComponents & Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`}
21
+ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
22
+ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
23
+
24
+ const __VLS_intrinsicElements: __VLS_IntrinsicElements;
25
+
26
+ // v-for
27
+ function __VLS_getVForSourceType(source: number): [number, number, number][];
28
+ function __VLS_getVForSourceType(source: string): [string, number, number][];
29
+ function __VLS_getVForSourceType<T extends any[]>(source: T): [
30
+ item: T[number],
31
+ key: number,
32
+ index: number,
33
+ ][];
34
+ function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
35
+ item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never,
36
+ key: number,
37
+ index: undefined,
38
+ ][];
39
+ // #3845
40
+ function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
41
+ item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never),
42
+ key: number,
43
+ index: undefined,
44
+ ][];
45
+ function __VLS_getVForSourceType<T>(source: T): [
46
+ item: T[keyof T],
47
+ key: keyof T,
48
+ index: number,
49
+ ][];
50
+
51
+ // @ts-ignore
52
+ function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
53
+ // @ts-ignore
54
+ function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
55
+
56
+ // Custom Directives
57
+ type __VLS_unknownDirective = (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
58
+ function __VLS_directiveAsFunction<T extends import('${vueCompilerOptions.lib}').Directive>(dir: T): T extends (...args: any) => any
59
+ ? T | __VLS_unknownDirective
60
+ : NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
61
+ const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any };
62
+
63
+ function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
64
+ function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
65
+ function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
66
+
67
+ type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
68
+ type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
69
+ N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N1] } :
70
+ N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N2] } :
71
+ N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N3] } :
72
+ N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
73
+ N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
74
+ N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
75
+ ${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
76
+
77
+ function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
78
+ T extends new (...args: any) => any
79
+ ? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
80
+ attrs?: any,
81
+ slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
82
+ emit?: K extends { $emit: infer Emit } ? Emit : any
83
+ } & { props?: ${fnPropsType}; expose?(exposed: K): void; } }
84
+ : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
85
+ : T extends (...args: any) => any ? T
86
+ : (_: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } };
87
+ function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
88
+ function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
89
+ function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<
90
+ '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
91
+ , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
92
+ >;
93
+ type __VLS_FunctionalComponentProps<T, K> =
94
+ '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
95
+ : T extends (props: infer P, ...args: any) => any ? P :
96
+ {};
97
+ type __VLS_IsFunction<T, K> = K extends keyof T
98
+ ? __VLS_IsAny<T[K]> extends false
99
+ ? unknown extends T[K]
100
+ ? false
101
+ : true
102
+ : false
103
+ : false;
104
+
105
+ function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
106
+ function __VLS_tryAsConstant<const T>(t: T): T;
107
+
108
+ /**
109
+ * emit
110
+ */
111
+ // fix https://github.com/vuejs/language-tools/issues/926
112
+ type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
113
+ type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
114
+ ? U extends T
115
+ ? never
116
+ : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
117
+ : never;
118
+ type __VLS_OverloadUnion<T> = Exclude<
119
+ __VLS_OverloadUnionInner<(() => never) & T>,
120
+ T extends () => never ? never : () => never
121
+ >;
122
+ type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
123
+ ? F extends (event: infer E, ...args: infer A) => any
124
+ ? { [K in E & string]: (...args: A) => void; }
125
+ : never
126
+ : never;
127
+ type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
128
+ __VLS_UnionToIntersection<
129
+ __VLS_ConstructorOverloads<T> & {
130
+ [K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
131
+ }
132
+ >
133
+ >;
134
+ type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
135
+ type __VLS_PickRefsExpose<T> = T extends object
136
+ ? { [K in keyof T]: (T[K] extends any[]
137
+ ? Parameters<T[K][0]['expose']>[0][]
138
+ : T[K] extends { expose?: (exposed: infer E) => void }
139
+ ? E
140
+ : T[K]) | null }
141
+ : never;
142
+ }
143
+ export const __VLS_globalTypesEnd = {};
144
+ `;
145
+ }
146
+ ;
147
+ //# sourceMappingURL=globalTypes.js.map
@@ -7,6 +7,7 @@ const context_1 = require("./context");
7
7
  const scriptSetup_1 = require("./scriptSetup");
8
8
  const src_1 = require("./src");
9
9
  const template_1 = require("./template");
10
+ const globalTypes_1 = require("../globalTypes");
10
11
  exports.codeFeatures = {
11
12
  all: {
12
13
  verification: true,
@@ -31,7 +32,12 @@ exports.codeFeatures = {
31
32
  };
32
33
  function* generateScript(options) {
33
34
  const ctx = (0, context_1.createScriptCodegenContext)(options);
34
- yield `/// <reference types="${options.vueCompilerOptions.lib}/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}" />${common_1.newLine}`;
35
+ if (options.vueCompilerOptions.__setupedGlobalTypes?.()) {
36
+ yield `/// <reference types=".vue-global-types/${options.vueCompilerOptions.lib}_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${common_1.newLine}`;
37
+ }
38
+ else {
39
+ yield `/* placeholder */`;
40
+ }
35
41
  if (options.sfc.script?.src) {
36
42
  yield* (0, src_1.generateSrc)(options.sfc.script, options.sfc.script.src);
37
43
  }
@@ -112,6 +118,9 @@ function* generateScript(options) {
112
118
  yield `type __VLS_IntrinsicElementsCompletion = __VLS_IntrinsicElements${common_1.endOfLine}`;
113
119
  }
114
120
  yield* ctx.localTypes.generate([...ctx.localTypes.getUsedNames()]);
121
+ if (!options.vueCompilerOptions.__setupedGlobalTypes?.()) {
122
+ yield (0, globalTypes_1.generateGlobalTypes)('local', options.vueCompilerOptions.lib, options.vueCompilerOptions.target, options.vueCompilerOptions.strictTemplates);
123
+ }
115
124
  if (options.sfc.scriptSetup) {
116
125
  yield ['', 'scriptSetup', options.sfc.scriptSetup.content.length, exports.codeFeatures.verification];
117
126
  }
@@ -40,9 +40,6 @@ function* generateInternalComponent(options, ctx, templateCodegenCtx) {
40
40
  }
41
41
  yield `}${common_1.endOfLine}`; // return {
42
42
  yield `},${common_1.newLine}`; // setup() {
43
- if (options.vueCompilerOptions.target >= 3.5) {
44
- yield `__typeRefs: {} as __VLS_Refs,${common_1.newLine}`;
45
- }
46
43
  if (options.sfc.scriptSetup && options.scriptSetupRanges && !ctx.bypassDefineComponent) {
47
44
  const emitOptionCodes = [...(0, component_1.generateEmitsOption)(options, options.sfc.scriptSetup, options.scriptSetupRanges)];
48
45
  for (const code of emitOptionCodes) {
@@ -221,7 +221,15 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
221
221
  }
222
222
  for (const { define } of scriptSetupRanges.templateRefs) {
223
223
  if (define?.arg) {
224
- setupCodeModifies.push([[`<__VLS_Refs[${scriptSetup.content.slice(define.arg.start, define.arg.end)}], keyof __VLS_Refs>`], define.arg.start - 1, define.arg.start - 1]);
224
+ setupCodeModifies.push([
225
+ [
226
+ `<__VLS_Refs[`,
227
+ (0, common_1.generateSfcBlockSection)(scriptSetup, define.arg.start, define.arg.end, index_1.codeFeatures.navigation),
228
+ `], keyof __VLS_Refs>`
229
+ ],
230
+ define.arg.start - 1,
231
+ define.arg.start - 1
232
+ ]);
225
233
  }
226
234
  }
227
235
  setupCodeModifies = setupCodeModifies.sort((a, b) => a[1] - b[1]);
@@ -13,20 +13,58 @@ const styleScopedClasses_1 = require("../template/styleScopedClasses");
13
13
  const index_1 = require("./index");
14
14
  const internalComponent_1 = require("./internalComponent");
15
15
  function* generateTemplateCtx(options, isClassComponent) {
16
- const types = [];
16
+ const baseExps = [];
17
+ const extraExps = [];
17
18
  if (isClassComponent) {
18
- types.push(`typeof this`);
19
+ baseExps.push(`this`);
19
20
  }
20
21
  else {
21
- types.push(`InstanceType<__VLS_PickNotAny<typeof __VLS_internalComponent, new () => {}>>`);
22
+ baseExps.push(`{} as InstanceType<__VLS_PickNotAny<typeof __VLS_internalComponent, new () => {}>>`);
22
23
  }
23
24
  if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.fileBaseName.endsWith(ext))) {
24
- types.push(`typeof globalThis`);
25
+ extraExps.push(`globalThis`);
25
26
  }
26
27
  if (options.sfc.styles.some(style => style.module)) {
27
- types.push(`__VLS_StyleModules`);
28
+ extraExps.push(`{} as __VLS_StyleModules`);
29
+ }
30
+ if (options.scriptSetupRanges?.templateRefs.length) {
31
+ let exp = `{} as import('${options.vueCompilerOptions.lib}').UnwrapRef<{${common_1.newLine}`;
32
+ for (const { name } of options.scriptSetupRanges.templateRefs) {
33
+ if (name) {
34
+ exp += `${name}: typeof ${name}${common_1.newLine}`;
35
+ }
36
+ }
37
+ exp += `}>${common_1.newLine}`;
38
+ extraExps.push(exp);
39
+ }
40
+ yield `const __VLS_ctxBase = `;
41
+ if (baseExps.length === 1) {
42
+ yield baseExps[0];
43
+ yield common_1.endOfLine;
44
+ }
45
+ else {
46
+ yield `{${common_1.newLine}`;
47
+ for (const exp of baseExps) {
48
+ yield `...`;
49
+ yield exp;
50
+ yield `,${common_1.newLine}`;
51
+ }
52
+ yield `}${common_1.endOfLine}`;
53
+ }
54
+ yield `const __VLS_ctx = `;
55
+ if (extraExps.length === 0) {
56
+ yield `__VLS_ctxBase${common_1.endOfLine}`;
57
+ }
58
+ else {
59
+ yield `{${common_1.newLine}`;
60
+ yield `...__VLS_ctxBase,${common_1.newLine}`;
61
+ for (const exp of extraExps) {
62
+ yield `...`;
63
+ yield exp;
64
+ yield `,${common_1.newLine}`;
65
+ }
66
+ yield `}${common_1.endOfLine}`;
28
67
  }
29
- yield `let __VLS_ctx!: ${types.join(' & ')}${common_1.endOfLine}`;
30
68
  }
31
69
  function* generateTemplateComponents(options) {
32
70
  const exps = [];
@@ -57,15 +95,15 @@ function* generateTemplateComponents(options) {
57
95
  }`);
58
96
  }
59
97
  exps.push(`{} as NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}>`);
60
- exps.push(`{} as __VLS_GlobalComponents`);
61
- exps.push(`{} as typeof __VLS_ctx`);
62
- yield `const __VLS_components = {${common_1.newLine}`;
98
+ exps.push(`__VLS_ctxBase`);
99
+ yield `const __VLS_localComponents = {${common_1.newLine}`;
63
100
  for (const type of exps) {
64
101
  yield `...`;
65
102
  yield type;
66
103
  yield `,${common_1.newLine}`;
67
104
  }
68
105
  yield `}${common_1.endOfLine}`;
106
+ yield `let __VLS_components: typeof __VLS_localComponents & __VLS_GlobalComponents${common_1.endOfLine}`;
69
107
  }
70
108
  function* generateTemplate(options, ctx, isClassComponent) {
71
109
  ctx.generatedTemplate = true;
@@ -76,7 +114,7 @@ function* generateTemplate(options, ctx, isClassComponent) {
76
114
  });
77
115
  yield* generateTemplateCtx(options, isClassComponent);
78
116
  yield* generateTemplateComponents(options);
79
- yield* generateTemplateBody(options, ctx, templateCodegenCtx);
117
+ yield* generateTemplateBody(options, templateCodegenCtx);
80
118
  yield* (0, internalComponent_1.generateInternalComponent)(options, ctx, templateCodegenCtx);
81
119
  }
82
120
  else {
@@ -86,7 +124,7 @@ function* generateTemplate(options, ctx, isClassComponent) {
86
124
  yield `const __VLS_templateResult { slots: {}, refs: {}, attrs: {} }${common_1.endOfLine}`;
87
125
  }
88
126
  }
89
- function* generateTemplateBody(options, ctx, templateCodegenCtx) {
127
+ function* generateTemplateBody(options, templateCodegenCtx) {
90
128
  const firstClasses = new Set();
91
129
  yield `let __VLS_styleScopedClasses!: {}`;
92
130
  for (let i = 0; i < options.sfc.styles.length; i++) {
@@ -119,13 +157,13 @@ function* generateTemplateBody(options, ctx, templateCodegenCtx) {
119
157
  yield `// no template${common_1.newLine}`;
120
158
  if (!options.scriptSetupRanges?.slots.define) {
121
159
  yield `const __VLS_slots = {}${common_1.endOfLine}`;
122
- yield `const __VLS_refs = {}${common_1.endOfLine}`;
160
+ yield `const $refs = {}${common_1.endOfLine}`;
123
161
  yield `const __VLS_inheritedAttrs = {}${common_1.endOfLine}`;
124
162
  }
125
163
  }
126
164
  yield `const __VLS_templateResult = {`;
127
165
  yield `slots: ${options.scriptSetupRanges?.slots.name ?? '__VLS_slots'},${common_1.newLine}`;
128
- yield `refs: __VLS_refs as ${ctx.localTypes.PickRefsExpose}<typeof __VLS_refs>,${common_1.newLine}`;
166
+ yield `refs: $refs,${common_1.newLine}`;
129
167
  yield `attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${common_1.newLine}`;
130
168
  yield `}${common_1.endOfLine}`;
131
169
  }
@@ -150,9 +150,18 @@ function* generateComponent(options, ctx, node, currentComponent) {
150
150
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, failedExp.node.loc.source, failedExp.node.loc, failedExp.node.loc.start.offset, ctx.codeFeatures.all, failedExp.prefix, failedExp.suffix);
151
151
  yield common_1.endOfLine;
152
152
  }
153
- const refName = yield* generateVScope(options, ctx, node, props);
153
+ const [refName, offset] = yield* generateVScope(options, ctx, node, props);
154
154
  if (refName) {
155
+ const varName = ctx.getInternalVariable();
156
+ options.templateRefNames.set(refName, [varName, offset]);
155
157
  ctx.usedComponentCtxVars.add(var_defineComponentCtx);
158
+ yield `var ${varName} = {} as (Parameters<typeof ${var_defineComponentCtx}['expose']>[0] | null)`;
159
+ if (node.codegenNode?.type === CompilerDOM.NodeTypes.VNODE_CALL
160
+ && node.codegenNode.props?.type === CompilerDOM.NodeTypes.JS_OBJECT_EXPRESSION
161
+ && node.codegenNode.props.properties.some(({ key }) => key.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && key.content === 'ref_for')) {
162
+ yield `[]`;
163
+ }
164
+ yield `${common_1.endOfLine}`;
156
165
  }
157
166
  const usedComponentEventsVar = yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, var_functionalComponent, var_componentInstance, var_componentEmit, var_componentEvents);
158
167
  if (usedComponentEventsVar) {
@@ -176,18 +185,6 @@ function* generateComponent(options, ctx, node, currentComponent) {
176
185
  }
177
186
  if (ctx.usedComponentCtxVars.has(var_defineComponentCtx)) {
178
187
  yield `const ${var_defineComponentCtx} = __VLS_pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance})${common_1.endOfLine}`;
179
- if (refName) {
180
- yield `// @ts-ignore${common_1.newLine}`;
181
- if (node.codegenNode?.type === CompilerDOM.NodeTypes.VNODE_CALL
182
- && node.codegenNode.props?.type === CompilerDOM.NodeTypes.JS_OBJECT_EXPRESSION
183
- && node.codegenNode.props.properties.find(({ key }) => key.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && key.content === 'ref_for')) {
184
- yield `(${refName} ??= []).push(${var_defineComponentCtx})`;
185
- }
186
- else {
187
- yield `${refName} = ${var_defineComponentCtx}`;
188
- }
189
- yield common_1.endOfLine;
190
- }
191
188
  }
192
189
  }
193
190
  function* generateElement(options, ctx, node, currentComponent, componentCtxVar) {
@@ -209,12 +206,9 @@ function* generateElement(options, ctx, node, currentComponent, componentCtxVar)
209
206
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, failedExp.node.loc.source, failedExp.node.loc, failedExp.node.loc.start.offset, ctx.codeFeatures.all, failedExp.prefix, failedExp.suffix);
210
207
  yield common_1.endOfLine;
211
208
  }
212
- const refName = yield* generateVScope(options, ctx, node, node.props);
209
+ const [refName, offset] = yield* generateVScope(options, ctx, node, node.props);
213
210
  if (refName) {
214
- yield `// @ts-ignore${common_1.newLine}`;
215
- yield `${refName} = __VLS_intrinsicElements`;
216
- yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag);
217
- yield common_1.endOfLine;
211
+ options.templateRefNames.set(refName, [`__VLS_intrinsicElements['${node.tag}']`, offset]);
218
212
  }
219
213
  const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot');
220
214
  if (slotDir && componentCtxVar) {
@@ -249,13 +243,13 @@ function* generateVScope(options, ctx, node, props) {
249
243
  inScope = true;
250
244
  }
251
245
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
252
- const refName = yield* generateReferencesForElements(options, ctx, node); // <el ref="foo" />
246
+ const [refName, offset] = yield* generateReferencesForElements(options, ctx, node); // <el ref="foo" />
253
247
  yield* generateReferencesForScopedCssClasses(options, ctx, node);
254
248
  if (inScope) {
255
249
  yield `}${common_1.newLine}`;
256
250
  ctx.blockConditions.length = originalConditionsNum;
257
251
  }
258
- return refName;
252
+ return [refName, offset];
259
253
  }
260
254
  function getCanonicalComponentName(tagText) {
261
255
  return common_1.variableNameRegex.test(tagText)
@@ -373,11 +367,10 @@ function* generateReferencesForElements(options, ctx, node) {
373
367
  if (common_1.variableNameRegex.test(content)) {
374
368
  ctx.accessExternalVariable(content, startOffset);
375
369
  }
376
- const refName = CompilerDOM.toValidAssetId(prop.value.content, '_VLS_refs');
377
- options.templateRefNames.set(prop.value.content, refName);
378
- return refName;
370
+ return [content, startOffset];
379
371
  }
380
372
  }
373
+ return [];
381
374
  }
382
375
  function* generateReferencesForScopedCssClasses(options, ctx, node) {
383
376
  for (const prop of node.props) {
@@ -10,7 +10,7 @@ export interface TemplateCodegenOptions {
10
10
  scriptSetupBindingNames: Set<string>;
11
11
  scriptSetupImportComponentNames: Set<string>;
12
12
  edited: boolean;
13
- templateRefNames: Map<string, string>;
13
+ templateRefNames: Map<string, [varName: string, offset: number]>;
14
14
  hasDefineSlots?: boolean;
15
15
  slotsAssignName?: string;
16
16
  propsAssignName?: string;
@@ -7,6 +7,7 @@ const common_1 = require("../common");
7
7
  const context_1 = require("./context");
8
8
  const element_1 = require("./element");
9
9
  const objectProperty_1 = require("./objectProperty");
10
+ const stringLiteralKey_1 = require("./stringLiteralKey");
10
11
  const templateChild_1 = require("./templateChild");
11
12
  const styleScopedClasses_1 = require("./styleScopedClasses");
12
13
  function* generateTemplate(options) {
@@ -17,6 +18,7 @@ function* generateTemplate(options) {
17
18
  if (options.propsAssignName) {
18
19
  ctx.addLocalVariable(options.propsAssignName);
19
20
  }
21
+ ctx.addLocalVariable('$refs');
20
22
  yield* generatePreResolveComponents();
21
23
  if (options.template.ast) {
22
24
  yield* (0, templateChild_1.generateTemplateChild)(options, ctx, options.template.ast, undefined, undefined, undefined);
@@ -32,14 +34,13 @@ function* generateTemplate(options) {
32
34
  yield* generateRefs();
33
35
  return ctx;
34
36
  function* generateRefs() {
35
- for (const [, validId] of options.templateRefNames) {
36
- yield `let ${validId}${common_1.newLine}`;
37
- }
38
37
  yield `const __VLS_refs = {${common_1.newLine}`;
39
- for (const [name, validId] of options.templateRefNames) {
40
- yield `'${name}': ${validId}!,${common_1.newLine}`;
38
+ for (const [name, [varName, offset]] of options.templateRefNames) {
39
+ yield* (0, stringLiteralKey_1.generateStringLiteralKey)(name, offset, ctx.codeFeatures.navigationAndCompletion);
40
+ yield `: ${varName},${common_1.newLine}`;
41
41
  }
42
42
  yield `}${common_1.endOfLine}`;
43
+ yield `declare var $refs: typeof __VLS_refs${common_1.endOfLine}`;
43
44
  }
44
45
  function* generateSlotsType() {
45
46
  for (const { expVar, varName } of ctx.dynamicSlots) {
@@ -80,7 +81,7 @@ function* generateTemplate(options) {
80
81
  }
81
82
  components.add(node.tag);
82
83
  yield common_1.newLine;
83
- yield ` & __VLS_WithComponent<'${(0, element_1.getCanonicalComponentName)(node.tag)}', typeof __VLS_components, `;
84
+ yield ` & __VLS_WithComponent<'${(0, element_1.getCanonicalComponentName)(node.tag)}', typeof __VLS_localComponents, `;
84
85
  yield (0, element_1.getPossibleOriginalComponentNames)(node.tag, false)
85
86
  .map(name => `"${name}"`)
86
87
  .join(', ');
@@ -0,0 +1,3 @@
1
+ import type * as CompilerDOM from '@vue/compiler-dom';
2
+ import type { InlayHintInfo } from "../types";
3
+ export declare function generateVBindShorthandInlayHint(loc: CompilerDOM.SourceLocation, variableName: string): InlayHintInfo;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateVBindShorthandInlayHint = generateVBindShorthandInlayHint;
4
+ function generateVBindShorthandInlayHint(loc, variableName) {
5
+ return {
6
+ blockName: 'template',
7
+ offset: loc.end.offset,
8
+ setting: 'vue.inlayHints.vBindShorthand',
9
+ label: `="${variableName}"`,
10
+ tooltip: [
11
+ `This is a shorthand for \`${loc.source}="${variableName}"\`.`,
12
+ 'To hide this hint, set `vue.inlayHints.vBindShorthand` to `false` in IDE settings.',
13
+ '[More info](https://github.com/vuejs/core/pull/9451)',
14
+ ].join('\n\n'),
15
+ };
16
+ }
17
+ ;
18
+ //# sourceMappingURL=vBindShorthand.js.map
@@ -19,10 +19,10 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
19
19
  const definePropProposalA = vueCompilerOptions.experimentalDefinePropProposal === 'kevinEdition' || ast.text.trimStart().startsWith('// @experimentalDefinePropProposal=kevinEdition');
20
20
  const definePropProposalB = vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition' || ast.text.trimStart().startsWith('// @experimentalDefinePropProposal=johnsonEdition');
21
21
  const defineProp = [];
22
- const bindings = parseBindingRanges(ts, ast);
23
22
  const text = ast.text;
24
23
  const leadingCommentEndOffset = ts.getLeadingCommentRanges(text, 0)?.reverse()[0].end ?? 0;
25
24
  const importComponentNames = new Set();
25
+ let bindings = parseBindingRanges(ts, ast);
26
26
  ts.forEachChild(ast, node => {
27
27
  const isTypeExport = (ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) && node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
28
28
  if (!foundNonImportExportNode
@@ -51,6 +51,11 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
51
51
  }
52
52
  });
53
53
  ts.forEachChild(ast, child => visitNode(child, [ast]));
54
+ const templateRefNames = new Set(templateRefs.map(ref => ref.name));
55
+ bindings = bindings.filter(range => {
56
+ const name = text.substring(range.start, range.end);
57
+ return !templateRefNames.has(name);
58
+ });
54
59
  return {
55
60
  leadingCommentEndOffset,
56
61
  importSectionEndOffset,
@@ -1,18 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const shouldAddSuffix = /(?<=<[^>/]+)$/;
3
4
  const plugin = ({ modules }) => {
4
5
  return {
5
6
  version: 2.1,
6
7
  compileSFCTemplate(lang, template, options) {
7
8
  if (lang === 'html' || lang === 'md') {
8
9
  const compiler = modules['@vue/compiler-dom'];
9
- return compiler.compile(template, {
10
+ let addedSuffix = false;
11
+ // #4583
12
+ if (shouldAddSuffix.test(template)) {
13
+ template += '>';
14
+ addedSuffix = true;
15
+ }
16
+ const result = compiler.compile(template, {
10
17
  ...options,
11
18
  comments: true,
12
19
  });
20
+ // @ts-expect-error
21
+ result.__addedSuffix = addedSuffix;
22
+ return result;
13
23
  }
14
24
  },
15
25
  updateSFCTemplate(oldResult, change) {
26
+ oldResult.code = oldResult.code.slice(0, change.start)
27
+ + change.newText
28
+ + oldResult.code.slice(change.end);
29
+ // @ts-expect-error
30
+ if (oldResult.__addedSuffix) {
31
+ const originalTemplate = oldResult.code.slice(0, -1); // remove added '>'
32
+ if (!shouldAddSuffix.test(originalTemplate)) {
33
+ return undefined;
34
+ }
35
+ }
16
36
  const CompilerDOM = modules['@vue/compiler-dom'];
17
37
  const lengthDiff = change.newText.length - (change.end - change.start);
18
38
  let hitNodes = [];
@@ -107,8 +127,16 @@ const plugin = ({ modules }) => {
107
127
  node.parseResult.key,
108
128
  node.parseResult.index,
109
129
  ]) {
110
- if (child && !tryUpdateNode(child)) {
111
- return false;
130
+ if (child) {
131
+ if (!tryUpdateNode(child)) {
132
+ return false;
133
+ }
134
+ if (child.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
135
+ const content = child.content.trim();
136
+ if (content.startsWith('(') || content.endsWith(')')) {
137
+ return false;
138
+ }
139
+ }
112
140
  }
113
141
  }
114
142
  for (const child of node.children) {
@@ -101,7 +101,6 @@ export declare const tsCodegen: WeakMap<Sfc, {
101
101
  readonly PropsChildren: string;
102
102
  readonly TypePropsToOption: string;
103
103
  readonly OmitIndexSignature: string;
104
- readonly PickRefsExpose: string;
105
104
  };
106
105
  inlayHints: import("../codegen/types").InlayHintInfo[];
107
106
  };
package/lib/types.d.ts CHANGED
@@ -45,6 +45,7 @@ export interface VueCompilerOptions {
45
45
  experimentalDefinePropProposal: 'kevinEdition' | 'johnsonEdition' | false;
46
46
  experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never';
47
47
  experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
48
+ __setupedGlobalTypes?: () => boolean;
48
49
  __test?: boolean;
49
50
  }
50
51
  export declare const validVersions: readonly [2, 2.1];
package/lib/utils/ts.js CHANGED
@@ -156,7 +156,7 @@ function getPartialVueCompilerOptions(ts, tsConfigSourceFile) {
156
156
  }
157
157
  function resolveVueCompilerOptions(vueOptions) {
158
158
  const target = vueOptions.target ?? 3.3;
159
- const lib = vueOptions.lib || (target < 2.7 ? '@vue/runtime-dom' : 'vue');
159
+ const lib = vueOptions.lib ?? 'vue';
160
160
  return {
161
161
  ...vueOptions,
162
162
  target,
@@ -172,7 +172,7 @@ function resolveVueCompilerOptions(vueOptions) {
172
172
  htmlAttributes: vueOptions.htmlAttributes ?? ['aria-*'],
173
173
  optionsWrapper: vueOptions.optionsWrapper ?? (target >= 2.7
174
174
  ? [`(await import('${lib}')).defineComponent(`, `)`]
175
- : [`(await import('vue')).default.extend(`, `)`]),
175
+ : [`(await import('${lib}')).default.extend(`, `)`]),
176
176
  macros: {
177
177
  defineProps: ['defineProps'],
178
178
  defineSlots: ['defineSlots'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.1.0",
3
+ "version": "2.1.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -36,5 +36,5 @@
36
36
  "optional": true
37
37
  }
38
38
  },
39
- "gitHead": "510063740b90b64caedaee1f0bde70974613a92c"
39
+ "gitHead": "5e197d08eaef57209ff2927c943ba1db3bf4eff6"
40
40
  }