Skip to content

Commit 2c87740

Browse files
committed
refactor: extract __VLS_ProxyRefs
1 parent c0b0b77 commit 2c87740

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/language-core/lib/codegen/globalTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
133133
};
134134
type __VLS_PrettifyGlobal<T> = { [K in keyof T as K]: T[K]; } & {};
135135
type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
136+
type __VLS_ProxyRefs<T> = import('${lib}').ShallowUnwrapRef<T>;
136137
137138
function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
138139
item: T extends number ? number

packages/language-core/lib/codegen/script/template.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ function* generateTemplateCtx(
7777
emitTypes.push(`typeof __VLS_modelEmit`);
7878
}
7979
if (emitTypes.length) {
80-
yield `type __VLS_ResolvedEmit = ${emitTypes.join(' & ')}${endOfLine}`;
81-
exps.push(`{} as { $emit: __VLS_ResolvedEmit }`);
80+
exps.push(`{} as { $emit: ${emitTypes.join(' & ')} }`);
8281
}
8382

84-
exps.push(`{} as import('${options.vueCompilerOptions.lib}').ShallowUnwrapRef<typeof __VLS_bindings>`);
83+
exps.push(`{} as __VLS_Bindings`);
8584

8685
yield `const __VLS_ctx = `;
8786
yield* generateSpreadMerge(exps);
@@ -185,7 +184,7 @@ function* generateBindings(
185184
options: ScriptCodegenOptions,
186185
ctx: ScriptCodegenContext,
187186
): Generator<Code> {
188-
yield `const __VLS_bindings = {${newLine}`;
187+
yield `type __VLS_Bindings = __VLS_ProxyRefs<{${newLine}`;
189188
if (options.sfc.scriptSetup && options.scriptSetupRanges) {
190189
const templateUsageVars = getTemplateUsageVars(options, ctx);
191190
for (
@@ -204,13 +203,13 @@ function* generateBindings(
204203

205204
const token = Symbol(varName.length);
206205
yield ['', undefined, 0, { __linkedToken: token }];
207-
yield `${varName}: ${varName} as typeof `;
206+
yield `${varName}: typeof `;
208207
yield ['', undefined, 0, { __linkedToken: token }];
209208
yield `${varName},${newLine}`;
210209
}
211210
}
212211
}
213-
yield `}${endOfLine}`;
212+
yield `}>${endOfLine}`;
214213
}
215214

216215
function getTemplateUsageVars(options: ScriptCodegenOptions, ctx: ScriptCodegenContext) {

0 commit comments

Comments
 (0)