Skip to content

Commit eb989b3

Browse files
committed
Merge branch 'master' of https://github.com/vuejs/language-tools into feat/local-vue-compiler-options
2 parents 5ea829a + 44f1c28 commit eb989b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2323
-26464
lines changed

.github/CODEOWNERS

-1
This file was deleted.

.github/workflows/update-html-data.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: update-html-data
22

33
on:
4+
push:
5+
branches:
6+
- 'master'
47
workflow_dispatch:
58
schedule:
69
- cron: '0 0 * * *'

extensions/vscode/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ Finally you need to make VS Code recognize your new extension and automatically
259259

260260
<!-- commands -->
261261

262-
| Command | Title |
263-
| ------------------------------ | ------------------------------------------------- |
264-
| `vue.action.restartServer` | Vue: Restart Vue and TS servers |
265-
| `vue.action.doctor` | Vue: Doctor |
266-
| `vue.action.writeVirtualFiles` | Vue (Debug): Write Virtual Files |
267-
| `vue.action.splitEditors` | Vue: Split <script>, <template>, <style> Editors |
268-
| `vue.findAllFileReferences` | Vue: Find File References via Vue Language Server |
262+
| Command | Title |
263+
| ------------------------------ | ------------------------------------------------------ |
264+
| `vue.action.restartServer` | Vue: Restart Vue and TS servers |
265+
| `vue.action.doctor` | Vue: Doctor |
266+
| `vue.action.writeVirtualFiles` | Vue (Debug): Write Virtual Files |
267+
| `vue.action.splitEditors` | Vue: Split &lt;script&gt;, <template>, <style> Editors |
268+
| `vue.findAllFileReferences` | Vue: Find File References via Vue Language Server |
269269

270270
<!-- commands -->
271271

@@ -292,7 +292,7 @@ Finally you need to make VS Code recognize your new extension and automatically
292292
| `vue.complete.casing.props` | Preferred attr name case. | `string` | `"autoKebab"` |
293293
| `vue.complete.defineAssignment` | Auto add `const props = ` before `defineProps` when selecting the completion item `props`. (also `emit` and `slots`) | `boolean` | `true` |
294294
| `vue.autoInsert.dotValue` | Auto-complete Ref value with `.value`. | `boolean` | `false` |
295-
| `vue.autoInsert.bracketSpacing` | Auto add space between double curly brackets: {{|}} -> {{ | }} | `boolean` | `true` |
295+
| `vue.autoInsert.bracketSpacing` | Auto add space between double curly brackets: {{&vert;}} -&gt; {{ | }} | `boolean` | `true` |
296296
| `vue.inlayHints.destructuredProps` | Show inlay hints for destructured props. | `boolean` | `false` |
297297
| `vue.inlayHints.missingProps` | Show inlay hints for missing required props. | `boolean` | `false` |
298298
| `vue.inlayHints.inlineHandlerLeading` | Show inlay hints for event argument in inline handlers. | `boolean` | `false` |

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
1515
const __VLS_intrinsicElements: __VLS_IntrinsicElements;
1616
const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any };
1717
const __VLS_unref: typeof import('${lib}').unref;
18+
const __VLS_placeholder: any;
1819
1920
const __VLS_nativeElements = {
2021
...{} as SVGElementTagNameMap,
@@ -47,7 +48,7 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
4748
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
4849
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
4950
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
50-
${strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
51+
${strictTemplates ? '{}' : '{ [K in N0]: unknown }'};
5152
type __VLS_FunctionalComponentProps<T, K> =
5253
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
5354
: T extends (props: infer P, ...args: any) => any ? P :
@@ -59,6 +60,15 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
5960
: true
6061
: false
6162
: false;
63+
type __VLS_NormalizeComponentEvent<Props, Events, onEvent extends keyof Props, Event extends keyof Events, CamelizedEvent extends keyof Events> = (
64+
__VLS_IsFunction<Props, onEvent> extends true
65+
? Props
66+
: __VLS_IsFunction<Events, Event> extends true
67+
? { [K in onEvent]?: Events[Event] }
68+
: __VLS_IsFunction<Events, CamelizedEvent> extends true
69+
? { [K in onEvent]?: Events[CamelizedEvent] }
70+
: Props
71+
)${strictTemplates ? '' : ' & Record<string, unknown>'};
6272
// fix https://github.com/vuejs/language-tools/issues/926
6373
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
6474
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export function* generateComponentSelf(
2727
? [options.sfc.script.content, options.scriptRanges.bindings] as const
2828
: ['', []] as const,
2929
]) {
30-
for (const expose of bindings) {
31-
const varName = content.slice(expose.start, expose.end);
30+
for (const { range } of bindings) {
31+
const varName = content.slice(range.start, range.end);
3232
if (!templateUsageVars.has(varName) && !templateCodegenCtx.accessExternalVariables.has(varName)) {
3333
continue;
3434
}

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export function createScriptCodegenContext(options: ScriptCodegenOptions) {
2121
scriptSetupGeneratedOffset: undefined as number | undefined,
2222
bypassDefineComponent: options.lang === 'js' || options.lang === 'jsx',
2323
bindingNames: new Set([
24-
...options.scriptRanges?.bindings.map(range => options.sfc.script!.content.slice(range.start, range.end)) ?? [],
25-
...options.scriptSetupRanges?.bindings.map(range => options.sfc.scriptSetup!.content.slice(range.start, range.end)) ?? [],
24+
...options.scriptRanges?.bindings.map(
25+
({ range }) => options.sfc.script!.content.slice(range.start, range.end)
26+
) ?? [],
27+
...options.scriptSetupRanges?.bindings.map(
28+
({ range }) => options.sfc.scriptSetup!.content.slice(range.start, range.end)
29+
) ?? [],
2630
]),
2731
localTypes,
2832
inlayHints,

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

-20
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
8484
&& options.sfc.script.content[exportDefault.expression.start] === '{';
8585
if (options.sfc.scriptSetup && options.scriptSetupRanges) {
8686
yield* generateScriptSetupImports(options.sfc.scriptSetup, options.scriptSetupRanges);
87-
yield* generateDefineProp(options);
8887
if (exportDefault) {
8988
yield generateSfcBlockSection(options.sfc.script, 0, exportDefault.expression.start, codeFeatures.all);
9089
yield* generateScriptSetup(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges);
@@ -141,7 +140,6 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
141140
}
142141
else if (options.sfc.scriptSetup && options.scriptSetupRanges) {
143142
yield* generateScriptSetupImports(options.sfc.scriptSetup, options.scriptSetupRanges);
144-
yield* generateDefineProp(options);
145143
yield* generateScriptSetup(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges);
146144
}
147145

@@ -182,21 +180,3 @@ export function* generateScriptSectionPartiallyEnding(source: string, end: numbe
182180
yield ['', source, end, codeFeatures.verification];
183181
yield `/* PartiallyEnd: ${mark} */${newLine}`;
184182
}
185-
186-
function* generateDefineProp(options: ScriptCodegenOptions): Generator<Code> {
187-
const definePropProposalA = options.vueCompilerOptions.experimentalDefinePropProposal === 'kevinEdition';
188-
const definePropProposalB = options.vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition';
189-
190-
if (definePropProposalA || definePropProposalB) {
191-
yield `type __VLS_PropOptions<T> = Exclude<import('${options.vueCompilerOptions.lib}').Prop<T>, import('${options.vueCompilerOptions.lib}').PropType<T>>${endOfLine}`;
192-
if (definePropProposalA) {
193-
yield `declare function defineProp<T>(name: string, options: ({ required: true } | { default: T }) & __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${endOfLine}`;
194-
yield `declare function defineProp<T>(name?: string, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${endOfLine}`;
195-
}
196-
if (definePropProposalB) {
197-
yield `declare function defineProp<T>(value: T | (() => T), required?: boolean, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${endOfLine}`;
198-
yield `declare function defineProp<T>(value: T | (() => T) | undefined, required: true, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${endOfLine}`;
199-
yield `declare function defineProp<T>(value?: T | (() => T), required?: boolean, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${endOfLine}`;
200-
}
201-
}
202-
}

0 commit comments

Comments
 (0)