Skip to content

Commit 310d10f

Browse files
authored
Merge branch 'master' into perf/drop-internal-component
2 parents 659de0a + 26fa104 commit 310d10f

File tree

21 files changed

+177
-125
lines changed

21 files changed

+177
-125
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 3.0.3 (2025-07-18)
4+
5+
### Bug Fixes
6+
7+
- fix(language-core): find `node_modules` based on file's directory (#5525) - Thanks to @KazariEX!
8+
- fix(language-core): do not spread exposed object (#5526) - Thanks to @KazariEX!
9+
- fix(vscode): prompt manual reload in remote envs (#5530)
10+
11+
### Other Changes
12+
13+
- refactor(tsc): return the result of runTsc (#5517) - Thanks to @escaton!
14+
315
## 3.0.2 (2025-07-18)
416

517
### Features
@@ -30,7 +42,7 @@
3042
- refactor(vscode): add premium feature settings
3143
- chore: migrate from `minimatch` to `picomatch` (#5499) - Thanks to @KazariEX!
3244
- chore: update volar to 2.4.19
33-
- fix(typescript): skip source file search when `.d.${ext}.ts` file exists (#277)
45+
- fix(typescript): skip source file search when `.d.${ext}.ts` file exists (volarjs/volar.js#277)
3446
- revert: type support of slot children (#5137) (#5514) - Thanks to @KazariEX!
3547

3648
## 3.0.1 (2025-07-02)

extensions/vscode/index.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import * as vscode from 'vscode';
1818
import { config } from './lib/config';
1919
import { activate as activateWelcome } from './lib/welcome';
2020

21+
let needRestart = false;
22+
2123
const incompatibleExtensionIds = [
2224
'johnsoncodehk.vscode-typescript-vue-plugin',
2325
'Vue.vscode-typescript-vue-plugin',
@@ -64,6 +66,27 @@ export const { activate, deactivate } = defineExtension(async () => {
6466

6567
nextTick(() => stop());
6668

69+
if (needRestart) {
70+
if (vscode.env.remoteName) {
71+
vscode.window.showInformationMessage(
72+
'Please restart the extension host to activate Vue support in remote environments.',
73+
'Restart Extension Host',
74+
'Reload Window',
75+
).then(action => {
76+
if (action === 'Restart Extension Host') {
77+
vscode.commands.executeCommand('workbench.action.restartExtensionHost');
78+
}
79+
else if (action === 'Reload Window') {
80+
vscode.commands.executeCommand('workbench.action.reloadWindow');
81+
}
82+
});
83+
}
84+
else {
85+
vscode.commands.executeCommand('workbench.action.restartExtensionHost');
86+
}
87+
return;
88+
}
89+
6790
watch(() => config.server.includeLanguages, async () => {
6891
const reload = await vscode.window.showInformationMessage(
6992
'Please restart extension host to apply the new language settings.',
@@ -219,7 +242,7 @@ try {
219242
}
220243

221244
if (tsExtension.isActive) {
222-
vscode.commands.executeCommand('workbench.action.restartExtensionHost');
245+
needRestart = true;
223246
}
224247
}
225248
catch {}

extensions/vscode/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "volar",
4-
"version": "3.0.2",
4+
"version": "3.0.3",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/vuejs/language-tools.git",
@@ -466,8 +466,8 @@
466466
"@volar/vscode": "2.4.20",
467467
"@vscode/vsce": "^3.2.1",
468468
"@vue/compiler-sfc": "^3.5.0",
469-
"@vue/language-server": "3.0.2",
470-
"@vue/typescript-plugin": "3.0.2",
469+
"@vue/language-server": "3.0.3",
470+
"@vue/typescript-plugin": "3.0.3",
471471
"reactive-vscode": "^0.2.9",
472472
"rolldown": "1.0.0-beta.8",
473473
"semver": "^7.5.4",

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"packages/**",
77
"test-workspace"
88
],
9-
"version": "3.0.2"
9+
"version": "3.0.3"
1010
}

packages/component-meta/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-component-meta",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"license": "MIT",
55
"files": [
66
"**/*.js",
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@volar/typescript": "2.4.20",
17-
"@vue/language-core": "3.0.2",
17+
"@vue/language-core": "3.0.3",
1818
"path-browserify": "^1.0.1"
1919
},
2020
"peerDependencies": {

packages/component-type-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-component-type-helpers",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"license": "MIT",
55
"files": [
66
"**/*.js",

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ const raw = {
7272
navigation: true,
7373
completion: true,
7474
},
75+
doNotReportTs2339AndTs2551: {
76+
verification: {
77+
// https://typescript.tv/errors/#ts2339
78+
// https://typescript.tv/errors/#ts2551
79+
shouldReport: (_source, code) => String(code) !== '2339' && String(code) !== '2551',
80+
},
81+
},
82+
doNotReportTs2353AndTs2561: {
83+
verification: {
84+
// https://typescript.tv/errors/#ts2353
85+
// https://typescript.tv/errors/#ts2561
86+
shouldReport: (_source, code) => String(code) !== '2353' && String(code) !== '2561',
87+
},
88+
},
89+
doNotReportTs6133: {
90+
verification: {
91+
// https://typescript.tv/errors/#ts6133
92+
shouldReport: (_source, code) => String(code) !== '6133',
93+
},
94+
},
7595
} satisfies Record<string, VueCodeInformation>;
7696

7797
export const codeFeatures = raw as {

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

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
import type { VueCompilerOptions } from '../types';
22
import { getSlotsPropertyName } from '../utils/shared';
33

4-
export function getGlobalTypesFileName({
5-
lib,
6-
target,
7-
checkUnknownProps,
8-
checkUnknownEvents,
9-
checkUnknownComponents,
10-
}: VueCompilerOptions) {
4+
export function getGlobalTypesFileName(options: VueCompilerOptions) {
115
return [
12-
lib,
13-
target,
14-
checkUnknownProps,
15-
checkUnknownEvents,
16-
checkUnknownComponents,
6+
options.lib,
7+
options.target,
8+
options.checkUnknownProps,
179
].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
1810
}
1911

20-
export function generateGlobalTypes({
21-
lib,
22-
target,
23-
checkUnknownProps,
24-
checkUnknownEvents,
25-
checkUnknownComponents,
26-
}: VueCompilerOptions) {
12+
export function generateGlobalTypes(options: VueCompilerOptions) {
13+
const { lib, target, checkUnknownProps } = options;
14+
2715
const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${
2816
checkUnknownProps ? '' : ' & Record<string, unknown>'
2917
}`;
@@ -69,7 +57,7 @@ export function generateGlobalTypes({
6957
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
7058
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
7159
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
72-
${checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }'};
60+
{};
7361
type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
7462
? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
7563
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
@@ -80,12 +68,12 @@ export function generateGlobalTypes({
8068
: {};
8169
type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
8270
__ctx?: {
83-
attrs?: any,
84-
slots?: T extends { ${getSlotsPropertyName(target)}: infer Slots } ? Slots : Record<string, any>,
85-
emit?: T extends { $emit: infer Emit } ? Emit : {},
86-
props?: ${fnPropsType},
87-
expose?: (exposed: T) => void,
88-
}
71+
attrs?: any;
72+
slots?: T extends { ${getSlotsPropertyName(target)}: infer Slots } ? Slots : Record<string, any>;
73+
emit?: T extends { $emit: infer Emit } ? Emit : {};
74+
props?: ${fnPropsType};
75+
expose?: (exposed: T) => void;
76+
};
8977
};
9078
type __VLS_IsFunction<T, K> = K extends keyof T
9179
? __VLS_IsAny<T[K]> extends false
@@ -94,15 +82,19 @@ export function generateGlobalTypes({
9482
: true
9583
: false
9684
: false;
97-
type __VLS_NormalizeComponentEvent<Props, Emits, onEvent extends keyof Props, Event extends keyof Emits, CamelizedEvent extends keyof Emits> = (
98-
__VLS_IsFunction<Props, onEvent> extends true
99-
? Props
100-
: __VLS_IsFunction<Emits, Event> extends true
101-
? { [K in onEvent]?: Emits[Event] }
102-
: __VLS_IsFunction<Emits, CamelizedEvent> extends true
103-
? { [K in onEvent]?: Emits[CamelizedEvent] }
104-
: Props
105-
)${checkUnknownEvents ? '' : ' & Record<string, unknown>'};
85+
type __VLS_NormalizeComponentEvent<
86+
Props,
87+
Emits,
88+
onEvent extends keyof Props,
89+
Event extends keyof Emits,
90+
CamelizedEvent extends keyof Emits,
91+
> = __VLS_IsFunction<Props, onEvent> extends true
92+
? Props
93+
: __VLS_IsFunction<Emits, Event> extends true
94+
? { [K in onEvent]?: Emits[Event] }
95+
: __VLS_IsFunction<Emits, CamelizedEvent> extends true
96+
? { [K in onEvent]?: Emits[CamelizedEvent] }
97+
: Props;
10698
// fix https://github.com/vuejs/language-tools/issues/926
10799
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
108100
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
@@ -178,7 +170,7 @@ export function generateGlobalTypes({
178170
: __VLS_FunctionalComponent<{}>;
179171
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
180172
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${
181-
checkUnknownComponents ? '' : ' & Record<string, unknown>'
173+
checkUnknownProps ? '' : ' & Record<string, unknown>'
182174
}) => void;
183175
function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
184176
function __VLS_tryAsConstant<const T>(t: T): T;

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ export function* generateComponent(
150150
yield* generateCanonicalComponentName(
151151
node.tag,
152152
tagOffsets[0],
153-
ctx.codeFeatures.withoutHighlightAndCompletionAndNavigation,
153+
ctx.resolveCodeFeatures({
154+
...codeFeatures.semanticWithoutHighlight,
155+
...options.vueCompilerOptions.checkUnknownComponents
156+
? codeFeatures.verification
157+
: codeFeatures.doNotReportTs2339AndTs2551,
158+
}),
154159
);
155160
yield `${endOfLine}`;
156161

@@ -205,14 +210,7 @@ export function* generateComponent(
205210
yield* wrapWith(
206211
node.loc.start.offset,
207212
node.loc.end.offset,
208-
ctx.resolveCodeFeatures({
209-
verification: {
210-
shouldReport(_source, code) {
211-
// https://typescript.tv/errors/#ts6133
212-
return String(code) !== '6133';
213-
},
214-
},
215-
}),
213+
ctx.codeFeatures.doNotReportTs6133,
216214
componentVNodeVar,
217215
);
218216
yield ` = ${componentFunctionalVar}`;

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as CompilerDOM from '@vue/compiler-dom';
22
import { camelize, capitalize } from '@vue/shared';
33
import type * as ts from 'typescript';
44
import type { Code, VueCodeInformation } from '../../types';
5+
import { codeFeatures } from '../codeFeatures';
56
import { combineLastMapping, createTsAst, endOfLine, identifierRegex, newLine } from '../utils';
67
import { generateCamelized } from '../utils/camelized';
78
import { wrapWith } from '../utils/wrapWith';
@@ -61,12 +62,12 @@ export function* generateElementEvents(
6162
yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${newLine}`;
6263
if (prop.name === 'on') {
6364
yield `{ `;
64-
yield* generateEventArg(ctx, source, start!, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation);
65+
yield* generateEventArg(options, ctx, source, start!, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation);
6566
yield `: {} as any } as typeof ${emitsVar},${newLine}`;
6667
}
6768
yield `{ `;
6869
if (prop.name === 'on') {
69-
yield* generateEventArg(ctx, source, start!, propPrefix.slice(0, -1));
70+
yield* generateEventArg(options, ctx, source, start!, propPrefix.slice(0, -1));
7071
yield `: `;
7172
yield* generateEventExpression(options, ctx, prop);
7273
}
@@ -80,15 +81,21 @@ export function* generateElementEvents(
8081
}
8182

8283
export function* generateEventArg(
84+
options: TemplateCodegenOptions,
8385
ctx: TemplateCodegenContext,
8486
name: string,
8587
start: number,
8688
directive = 'on',
87-
features: VueCodeInformation = {
88-
...ctx.codeFeatures.withoutHighlightAndCompletion,
89-
...ctx.codeFeatures.navigationWithoutRename,
90-
},
89+
features?: VueCodeInformation,
9190
): Generator<Code> {
91+
features ??= ctx.resolveCodeFeatures({
92+
...codeFeatures.semanticWithoutHighlight,
93+
...codeFeatures.navigationWithoutRename,
94+
...options.vueCompilerOptions.checkUnknownEvents
95+
? codeFeatures.verification
96+
: codeFeatures.doNotReportTs2353AndTs2561,
97+
});
98+
9299
if (directive.length) {
93100
name = capitalize(name);
94101
}

0 commit comments

Comments
 (0)