@vue/language-core 3.0.3 → 3.0.5
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.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/codegen/codeFeatures.d.ts +20 -17
- package/lib/codegen/codeFeatures.js +23 -13
- package/lib/codegen/globalTypes.d.ts +2 -2
- package/lib/codegen/globalTypes.js +27 -24
- package/lib/codegen/script/context.d.ts +0 -6
- package/lib/codegen/script/index.d.ts +2 -1
- package/lib/codegen/script/index.js +16 -4
- package/lib/codegen/script/scriptSetup.js +4 -5
- package/lib/codegen/template/context.d.ts +0 -19
- package/lib/codegen/template/context.js +0 -6
- package/lib/codegen/template/element.js +23 -21
- package/lib/codegen/template/elementDirectives.js +10 -10
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +23 -20
- package/lib/codegen/template/elementProps.js +17 -24
- package/lib/codegen/template/index.d.ts +3 -2
- package/lib/codegen/template/index.js +21 -8
- package/lib/codegen/template/interpolation.js +5 -3
- package/lib/codegen/template/slotOutlet.js +6 -5
- package/lib/codegen/template/styleScopedClasses.js +3 -2
- package/lib/codegen/template/templateChild.js +2 -1
- package/lib/codegen/template/vFor.js +6 -4
- package/lib/codegen/template/vIf.js +2 -1
- package/lib/codegen/template/vSlot.js +11 -9
- package/lib/codegen/tenp.d.ts +1 -0
- package/lib/codegen/tenp.js +3 -0
- package/lib/codegen/utils/index.d.ts +0 -10
- package/lib/codegen/utils/index.js +0 -27
- package/lib/parsers/scriptSetupRanges.d.ts +0 -1
- package/lib/parsers/scriptSetupRanges.js +4 -40
- package/lib/parsers/utils.d.ts +12 -0
- package/lib/parsers/utils.js +95 -0
- package/lib/plugins/file-css.d.ts +3 -0
- package/lib/plugins/file-css.js +57 -0
- package/lib/plugins/file-vue.js +16 -1
- package/lib/plugins/vue-root-tags.js +2 -9
- package/lib/plugins/vue-style-css.d.ts +3 -0
- package/lib/plugins/vue-style-css.js +62 -0
- package/lib/plugins/vue-tsx.d.ts +2 -20
- package/lib/plugins/vue-tsx.js +18 -20
- package/lib/types.d.ts +1 -1
- package/lib/utils/collectBindings.d.ts +12 -0
- package/lib/utils/collectBindings.js +29 -0
- package/lib/utils/ts.js +20 -18
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './lib/codegen/globalTypes';
|
|
2
2
|
export * from './lib/codegen/template';
|
|
3
|
-
export * from './lib/codegen/utils';
|
|
4
3
|
export * from './lib/languagePlugin';
|
|
5
4
|
export * from './lib/parsers/scriptSetupRanges';
|
|
6
5
|
export * from './lib/plugins';
|
|
7
6
|
export * from './lib/types';
|
|
7
|
+
export * from './lib/utils/collectBindings';
|
|
8
8
|
export * from './lib/utils/parseSfc';
|
|
9
9
|
export * from './lib/utils/shared';
|
|
10
10
|
export * from './lib/utils/ts';
|
package/index.js
CHANGED
|
@@ -17,11 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.tsCodegen = void 0;
|
|
18
18
|
__exportStar(require("./lib/codegen/globalTypes"), exports);
|
|
19
19
|
__exportStar(require("./lib/codegen/template"), exports);
|
|
20
|
-
__exportStar(require("./lib/codegen/utils"), exports);
|
|
21
20
|
__exportStar(require("./lib/languagePlugin"), exports);
|
|
22
21
|
__exportStar(require("./lib/parsers/scriptSetupRanges"), exports);
|
|
23
22
|
__exportStar(require("./lib/plugins"), exports);
|
|
24
23
|
__exportStar(require("./lib/types"), exports);
|
|
24
|
+
__exportStar(require("./lib/utils/collectBindings"), exports);
|
|
25
25
|
__exportStar(require("./lib/utils/parseSfc"), exports);
|
|
26
26
|
__exportStar(require("./lib/utils/shared"), exports);
|
|
27
27
|
__exportStar(require("./lib/utils/ts"), exports);
|
|
@@ -25,15 +25,16 @@ declare const raw: {
|
|
|
25
25
|
navigation: {
|
|
26
26
|
navigation: true;
|
|
27
27
|
};
|
|
28
|
+
navigationWithoutHighlight: {
|
|
29
|
+
navigation: {
|
|
30
|
+
shouldHighlight: () => false;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
28
33
|
navigationWithoutRename: {
|
|
29
34
|
navigation: {
|
|
30
35
|
shouldRename: () => false;
|
|
31
36
|
};
|
|
32
37
|
};
|
|
33
|
-
navigationAndCompletion: {
|
|
34
|
-
navigation: true;
|
|
35
|
-
completion: true;
|
|
36
|
-
};
|
|
37
38
|
navigationAndAdditionalCompletion: {
|
|
38
39
|
navigation: true;
|
|
39
40
|
completion: {
|
|
@@ -62,13 +63,6 @@ declare const raw: {
|
|
|
62
63
|
navigation: true;
|
|
63
64
|
completion: true;
|
|
64
65
|
};
|
|
65
|
-
withoutHighlightAndNavigation: {
|
|
66
|
-
semantic: {
|
|
67
|
-
shouldHighlight: () => false;
|
|
68
|
-
};
|
|
69
|
-
verification: true;
|
|
70
|
-
completion: true;
|
|
71
|
-
};
|
|
72
66
|
withoutHighlightAndCompletion: {
|
|
73
67
|
semantic: {
|
|
74
68
|
shouldHighlight: () => false;
|
|
@@ -76,17 +70,26 @@ declare const raw: {
|
|
|
76
70
|
verification: true;
|
|
77
71
|
navigation: true;
|
|
78
72
|
};
|
|
79
|
-
withoutHighlightAndCompletionAndNavigation: {
|
|
80
|
-
semantic: {
|
|
81
|
-
shouldHighlight: () => false;
|
|
82
|
-
};
|
|
83
|
-
verification: true;
|
|
84
|
-
};
|
|
85
73
|
withoutSemantic: {
|
|
86
74
|
verification: true;
|
|
87
75
|
navigation: true;
|
|
88
76
|
completion: true;
|
|
89
77
|
};
|
|
78
|
+
doNotReportTs2339AndTs2551: {
|
|
79
|
+
verification: {
|
|
80
|
+
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
doNotReportTs2353AndTs2561: {
|
|
84
|
+
verification: {
|
|
85
|
+
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
doNotReportTs6133: {
|
|
89
|
+
verification: {
|
|
90
|
+
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
90
93
|
};
|
|
91
94
|
export declare const codeFeatures: { [K in keyof typeof raw]: VueCodeInformation; };
|
|
92
95
|
export {};
|
|
@@ -25,13 +25,12 @@ const raw = {
|
|
|
25
25
|
navigation: {
|
|
26
26
|
navigation: true,
|
|
27
27
|
},
|
|
28
|
+
navigationWithoutHighlight: {
|
|
29
|
+
navigation: { shouldHighlight: () => false },
|
|
30
|
+
},
|
|
28
31
|
navigationWithoutRename: {
|
|
29
32
|
navigation: { shouldRename: () => false },
|
|
30
33
|
},
|
|
31
|
-
navigationAndCompletion: {
|
|
32
|
-
navigation: true,
|
|
33
|
-
completion: true,
|
|
34
|
-
},
|
|
35
34
|
navigationAndAdditionalCompletion: {
|
|
36
35
|
navigation: true,
|
|
37
36
|
completion: { isAdditional: true },
|
|
@@ -54,25 +53,36 @@ const raw = {
|
|
|
54
53
|
navigation: true,
|
|
55
54
|
completion: true,
|
|
56
55
|
},
|
|
57
|
-
withoutHighlightAndNavigation: {
|
|
58
|
-
semantic: { shouldHighlight: () => false },
|
|
59
|
-
verification: true,
|
|
60
|
-
completion: true,
|
|
61
|
-
},
|
|
62
56
|
withoutHighlightAndCompletion: {
|
|
63
57
|
semantic: { shouldHighlight: () => false },
|
|
64
58
|
verification: true,
|
|
65
59
|
navigation: true,
|
|
66
60
|
},
|
|
67
|
-
withoutHighlightAndCompletionAndNavigation: {
|
|
68
|
-
semantic: { shouldHighlight: () => false },
|
|
69
|
-
verification: true,
|
|
70
|
-
},
|
|
71
61
|
withoutSemantic: {
|
|
72
62
|
verification: true,
|
|
73
63
|
navigation: true,
|
|
74
64
|
completion: true,
|
|
75
65
|
},
|
|
66
|
+
doNotReportTs2339AndTs2551: {
|
|
67
|
+
verification: {
|
|
68
|
+
// https://typescript.tv/errors/#ts2339
|
|
69
|
+
// https://typescript.tv/errors/#ts2551
|
|
70
|
+
shouldReport: (_source, code) => String(code) !== '2339' && String(code) !== '2551',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
doNotReportTs2353AndTs2561: {
|
|
74
|
+
verification: {
|
|
75
|
+
// https://typescript.tv/errors/#ts2353
|
|
76
|
+
// https://typescript.tv/errors/#ts2561
|
|
77
|
+
shouldReport: (_source, code) => String(code) !== '2353' && String(code) !== '2561',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
doNotReportTs6133: {
|
|
81
|
+
verification: {
|
|
82
|
+
// https://typescript.tv/errors/#ts6133
|
|
83
|
+
shouldReport: (_source, code) => String(code) !== '6133',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
76
86
|
};
|
|
77
87
|
exports.codeFeatures = raw;
|
|
78
88
|
//# sourceMappingURL=codeFeatures.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VueCompilerOptions } from '../types';
|
|
2
|
-
export declare function getGlobalTypesFileName(
|
|
3
|
-
export declare function generateGlobalTypes(
|
|
2
|
+
export declare function getGlobalTypesFileName(options: VueCompilerOptions): string;
|
|
3
|
+
export declare function generateGlobalTypes(options: VueCompilerOptions): string;
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGlobalTypesFileName = getGlobalTypesFileName;
|
|
4
4
|
exports.generateGlobalTypes = generateGlobalTypes;
|
|
5
5
|
const shared_1 = require("../utils/shared");
|
|
6
|
-
function getGlobalTypesFileName(
|
|
6
|
+
function getGlobalTypesFileName(options) {
|
|
7
7
|
return [
|
|
8
|
-
lib,
|
|
9
|
-
target,
|
|
10
|
-
checkUnknownProps,
|
|
11
|
-
checkUnknownEvents,
|
|
12
|
-
checkUnknownComponents,
|
|
8
|
+
options.lib,
|
|
9
|
+
options.target,
|
|
10
|
+
options.checkUnknownProps,
|
|
13
11
|
].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
|
|
14
12
|
}
|
|
15
|
-
function generateGlobalTypes(
|
|
13
|
+
function generateGlobalTypes(options) {
|
|
14
|
+
const { lib, target, checkUnknownProps } = options;
|
|
16
15
|
const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
|
|
17
16
|
let text = `// @ts-nocheck\nexport {};\n`;
|
|
18
17
|
if (target < 3.5) {
|
|
@@ -50,7 +49,7 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
|
|
|
50
49
|
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
|
|
51
50
|
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
|
|
52
51
|
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
|
|
53
|
-
|
|
52
|
+
{};
|
|
54
53
|
type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
|
|
55
54
|
? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
|
|
56
55
|
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
|
|
@@ -61,12 +60,12 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
|
|
|
61
60
|
: {};
|
|
62
61
|
type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
|
|
63
62
|
__ctx?: {
|
|
64
|
-
attrs?: any
|
|
65
|
-
slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any
|
|
66
|
-
emit?: T extends { $emit: infer Emit } ? Emit : {}
|
|
67
|
-
props?: ${fnPropsType}
|
|
68
|
-
expose?: (exposed: T) => void
|
|
69
|
-
}
|
|
63
|
+
attrs?: any;
|
|
64
|
+
slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>;
|
|
65
|
+
emit?: T extends { $emit: infer Emit } ? Emit : {};
|
|
66
|
+
props?: ${fnPropsType};
|
|
67
|
+
expose?: (exposed: T) => void;
|
|
68
|
+
};
|
|
70
69
|
};
|
|
71
70
|
type __VLS_IsFunction<T, K> = K extends keyof T
|
|
72
71
|
? __VLS_IsAny<T[K]> extends false
|
|
@@ -75,15 +74,19 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
|
|
|
75
74
|
: true
|
|
76
75
|
: false
|
|
77
76
|
: false;
|
|
78
|
-
type __VLS_NormalizeComponentEvent<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
type __VLS_NormalizeComponentEvent<
|
|
78
|
+
Props,
|
|
79
|
+
Emits,
|
|
80
|
+
onEvent extends keyof Props,
|
|
81
|
+
Event extends keyof Emits,
|
|
82
|
+
CamelizedEvent extends keyof Emits,
|
|
83
|
+
> = __VLS_IsFunction<Props, onEvent> extends true
|
|
84
|
+
? Props
|
|
85
|
+
: __VLS_IsFunction<Emits, Event> extends true
|
|
86
|
+
? { [K in onEvent]?: Emits[Event] }
|
|
87
|
+
: __VLS_IsFunction<Emits, CamelizedEvent> extends true
|
|
88
|
+
? { [K in onEvent]?: Emits[CamelizedEvent] }
|
|
89
|
+
: Props;
|
|
87
90
|
// fix https://github.com/vuejs/language-tools/issues/926
|
|
88
91
|
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
|
|
89
92
|
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
|
|
@@ -150,7 +153,7 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
|
|
|
150
153
|
: T extends (...args: any) => any ? T
|
|
151
154
|
: __VLS_FunctionalComponent<{}>;
|
|
152
155
|
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
|
|
153
|
-
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${
|
|
156
|
+
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownProps ? '' : ' & Record<string, unknown>'}) => void;
|
|
154
157
|
function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
|
|
155
158
|
function __VLS_tryAsConstant<const T>(t: T): T;
|
|
156
159
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { InlayHintInfo } from '../inlayHints';
|
|
2
2
|
import type { ScriptCodegenOptions } from './index';
|
|
3
|
-
export interface HelperType {
|
|
4
|
-
name: string;
|
|
5
|
-
used?: boolean;
|
|
6
|
-
generated?: boolean;
|
|
7
|
-
code: string;
|
|
8
|
-
}
|
|
9
3
|
export type ScriptCodegenContext = ReturnType<typeof createScriptCodegenContext>;
|
|
10
4
|
export declare function createScriptCodegenContext(options: ScriptCodegenOptions): {
|
|
11
5
|
generatedTemplate: boolean;
|
|
@@ -4,6 +4,7 @@ import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges';
|
|
|
4
4
|
import type { Code, Sfc, VueCompilerOptions } from '../../types';
|
|
5
5
|
import type { TemplateCodegenContext } from '../template/context';
|
|
6
6
|
import { type ScriptCodegenContext } from './context';
|
|
7
|
+
export * from './context';
|
|
7
8
|
export interface ScriptCodegenOptions {
|
|
8
9
|
ts: typeof ts;
|
|
9
10
|
compilerOptions: ts.CompilerOptions;
|
|
@@ -19,5 +20,5 @@ export interface ScriptCodegenOptions {
|
|
|
19
20
|
destructuredPropNames: Set<string>;
|
|
20
21
|
templateRefNames: Set<string>;
|
|
21
22
|
}
|
|
22
|
-
export declare function generateScript(options: ScriptCodegenOptions): Generator<Code
|
|
23
|
+
export declare function generateScript(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;
|
|
23
24
|
export declare function generateScriptSectionPartiallyEnding(source: string, end: number, mark: string, delimiter?: string): Generator<Code>;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.generateScript = generateScript;
|
|
4
18
|
exports.generateScriptSectionPartiallyEnding = generateScriptSectionPartiallyEnding;
|
|
@@ -6,12 +20,11 @@ const path = require("path-browserify");
|
|
|
6
20
|
const codeFeatures_1 = require("../codeFeatures");
|
|
7
21
|
const utils_1 = require("../utils");
|
|
8
22
|
const componentSelf_1 = require("./componentSelf");
|
|
9
|
-
const context_1 = require("./context");
|
|
10
23
|
const scriptSetup_1 = require("./scriptSetup");
|
|
11
24
|
const src_1 = require("./src");
|
|
12
25
|
const template_1 = require("./template");
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
__exportStar(require("./context"), exports);
|
|
27
|
+
function* generateScript(options, ctx) {
|
|
15
28
|
yield* generateGlobalTypesPath(options);
|
|
16
29
|
if (options.sfc.script?.src) {
|
|
17
30
|
yield* (0, src_1.generateSrc)(options.sfc.script.src);
|
|
@@ -93,7 +106,6 @@ function* generateScript(options) {
|
|
|
93
106
|
if (options.sfc.scriptSetup) {
|
|
94
107
|
yield ['', 'scriptSetup', options.sfc.scriptSetup.content.length, codeFeatures_1.codeFeatures.verification];
|
|
95
108
|
}
|
|
96
|
-
return ctx;
|
|
97
109
|
}
|
|
98
110
|
function* generateGlobalTypesPath(options) {
|
|
99
111
|
const globalTypesPath = options.vueCompilerOptions.globalTypesPath(options.fileName);
|
|
@@ -248,10 +248,9 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
|
|
|
248
248
|
const templateCodegenCtx = yield* (0, template_1.generateTemplate)(options, ctx);
|
|
249
249
|
yield* (0, componentSelf_1.generateComponentSelf)(options, ctx, templateCodegenCtx);
|
|
250
250
|
if (syntax) {
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|| options.templateCodegen?.dynamicSlots.length)) {
|
|
251
|
+
if (scriptSetupRanges.defineSlots
|
|
252
|
+
|| options.templateCodegen?.slots.length
|
|
253
|
+
|| options.templateCodegen?.dynamicSlots.length) {
|
|
255
254
|
yield `const __VLS_component = `;
|
|
256
255
|
yield* (0, component_1.generateComponent)(options, ctx, scriptSetup, scriptSetupRanges);
|
|
257
256
|
yield utils_1.endOfLine;
|
|
@@ -401,7 +400,7 @@ function* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
|
401
400
|
yield* generateDefineModelType(scriptSetup, propName, localName, defineModel);
|
|
402
401
|
yield `,${utils_1.newLine}`;
|
|
403
402
|
if (defineModel.modifierType) {
|
|
404
|
-
const modifierName = `${
|
|
403
|
+
const modifierName = `${propName === 'modelValue' ? 'model' : propName}Modifiers`;
|
|
405
404
|
const modifierType = getRangeText(scriptSetup, defineModel.modifierType);
|
|
406
405
|
yield `'${modifierName}'?: Partial<Record<${modifierType}, true>>,${utils_1.newLine}`;
|
|
407
406
|
}
|
|
@@ -112,25 +112,6 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
|
|
|
112
112
|
offset: number;
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
|
-
codeFeatures: {
|
|
116
|
-
all: VueCodeInformation;
|
|
117
|
-
verification: VueCodeInformation;
|
|
118
|
-
completion: VueCodeInformation;
|
|
119
|
-
additionalCompletion: VueCodeInformation;
|
|
120
|
-
withoutCompletion: VueCodeInformation;
|
|
121
|
-
navigation: VueCodeInformation;
|
|
122
|
-
navigationWithoutRename: VueCodeInformation;
|
|
123
|
-
navigationAndCompletion: VueCodeInformation;
|
|
124
|
-
navigationAndAdditionalCompletion: VueCodeInformation;
|
|
125
|
-
navigationAndVerification: VueCodeInformation;
|
|
126
|
-
withoutNavigation: VueCodeInformation;
|
|
127
|
-
semanticWithoutHighlight: VueCodeInformation;
|
|
128
|
-
withoutHighlight: VueCodeInformation;
|
|
129
|
-
withoutHighlightAndNavigation: VueCodeInformation;
|
|
130
|
-
withoutHighlightAndCompletion: VueCodeInformation;
|
|
131
|
-
withoutHighlightAndCompletionAndNavigation: VueCodeInformation;
|
|
132
|
-
withoutSemantic: VueCodeInformation;
|
|
133
|
-
};
|
|
134
115
|
resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation;
|
|
135
116
|
inlineTsAsts: Map<string, import("typescript").SourceFile> | undefined;
|
|
136
117
|
inVFor: boolean;
|
|
@@ -154,12 +154,6 @@ function createTemplateCodegenContext(options, templateAst) {
|
|
|
154
154
|
get currentInfo() {
|
|
155
155
|
return stack[stack.length - 1];
|
|
156
156
|
},
|
|
157
|
-
codeFeatures: new Proxy(codeFeatures_1.codeFeatures, {
|
|
158
|
-
get(target, key) {
|
|
159
|
-
const data = target[key];
|
|
160
|
-
return resolveCodeFeatures(data);
|
|
161
|
-
},
|
|
162
|
-
}),
|
|
163
157
|
resolveCodeFeatures,
|
|
164
158
|
inlineTsAsts: templateAst && computedSfc_1.templateInlineTsAsts.get(templateAst),
|
|
165
159
|
inVFor: false,
|
|
@@ -76,12 +76,12 @@ function* generateComponent(options, ctx, node) {
|
|
|
76
76
|
componentOriginalVar,
|
|
77
77
|
'template',
|
|
78
78
|
tagOffset,
|
|
79
|
-
|
|
79
|
+
codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
|
|
80
80
|
];
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
const shouldCapitalize = matchImportName[0].toUpperCase() === matchImportName[0];
|
|
84
|
-
yield* (0, camelized_1.generateCamelized)(shouldCapitalize ? (0, shared_1.capitalize)(node.tag) : node.tag, 'template', tagOffset,
|
|
84
|
+
yield* (0, camelized_1.generateCamelized)(shouldCapitalize ? (0, shared_1.capitalize)(node.tag) : node.tag, 'template', tagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
|
|
85
85
|
}
|
|
86
86
|
yield `, `;
|
|
87
87
|
}
|
|
@@ -89,10 +89,10 @@ function* generateComponent(options, ctx, node) {
|
|
|
89
89
|
}
|
|
90
90
|
else if (dynamicTagInfo) {
|
|
91
91
|
yield `const ${componentOriginalVar} = (`;
|
|
92
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template',
|
|
92
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, dynamicTagInfo.tag, dynamicTagInfo.offsets[0], `(`, `)`);
|
|
93
93
|
if (dynamicTagInfo.offsets[1] !== undefined) {
|
|
94
94
|
yield `,`;
|
|
95
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template',
|
|
95
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.withoutCompletion, dynamicTagInfo.tag, dynamicTagInfo.offsets[1], `(`, `)`);
|
|
96
96
|
}
|
|
97
97
|
yield `)${utils_1.endOfLine}`;
|
|
98
98
|
}
|
|
@@ -110,7 +110,12 @@ function* generateComponent(options, ctx, node) {
|
|
|
110
110
|
.map(name => `'${name}'`)
|
|
111
111
|
.join(`, `);
|
|
112
112
|
yield `>).`;
|
|
113
|
-
yield* generateCanonicalComponentName(node.tag, tagOffsets[0],
|
|
113
|
+
yield* generateCanonicalComponentName(node.tag, tagOffsets[0], {
|
|
114
|
+
...codeFeatures_1.codeFeatures.semanticWithoutHighlight,
|
|
115
|
+
...options.vueCompilerOptions.checkUnknownComponents
|
|
116
|
+
? codeFeatures_1.codeFeatures.verification
|
|
117
|
+
: codeFeatures_1.codeFeatures.doNotReportTs2339AndTs2551,
|
|
118
|
+
});
|
|
114
119
|
yield `${utils_1.endOfLine}`;
|
|
115
120
|
const camelizedTag = (0, shared_1.camelize)(node.tag);
|
|
116
121
|
if (utils_1.identifierRegex.test(camelizedTag)) {
|
|
@@ -140,18 +145,11 @@ function* generateComponent(options, ctx, node) {
|
|
|
140
145
|
yield* (0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, false);
|
|
141
146
|
yield `}))${utils_1.endOfLine}`;
|
|
142
147
|
yield `const `;
|
|
143
|
-
yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset,
|
|
144
|
-
verification: {
|
|
145
|
-
shouldReport(_source, code) {
|
|
146
|
-
// https://typescript.tv/errors/#ts6133
|
|
147
|
-
return String(code) !== '6133';
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
}), componentVNodeVar);
|
|
148
|
+
yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.doNotReportTs6133, componentVNodeVar);
|
|
151
149
|
yield ` = ${componentFunctionalVar}`;
|
|
152
150
|
yield* generateComponentGeneric(ctx);
|
|
153
151
|
yield `(`;
|
|
154
|
-
yield* (0, wrapWith_1.wrapWith)(tagOffsets[0], tagOffsets[0] + node.tag.length,
|
|
152
|
+
yield* (0, wrapWith_1.wrapWith)(tagOffsets[0], tagOffsets[0] + node.tag.length, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
|
|
155
153
|
yield `, ...__VLS_functionalComponentArgsRest(${componentFunctionalVar}))${utils_1.endOfLine}`;
|
|
156
154
|
yield* generateFailedPropExps(options, ctx, failedPropExps);
|
|
157
155
|
yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentOriginalVar, componentFunctionalVar, componentVNodeVar, componentCtxVar);
|
|
@@ -194,14 +192,18 @@ function* generateElement(options, ctx, node) {
|
|
|
194
192
|
? node.loc.start.offset + node.loc.source.lastIndexOf(node.tag)
|
|
195
193
|
: undefined;
|
|
196
194
|
const failedPropExps = [];
|
|
195
|
+
const features = {
|
|
196
|
+
...codeFeatures_1.codeFeatures.semanticWithoutHighlight,
|
|
197
|
+
...codeFeatures_1.codeFeatures.navigationWithoutHighlight,
|
|
198
|
+
};
|
|
197
199
|
yield `__VLS_asFunctionalElement(__VLS_elements`;
|
|
198
|
-
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset,
|
|
200
|
+
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, features);
|
|
199
201
|
if (endTagOffset !== undefined) {
|
|
200
202
|
yield `, __VLS_elements`;
|
|
201
|
-
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset,
|
|
203
|
+
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, features);
|
|
202
204
|
}
|
|
203
205
|
yield `)(`;
|
|
204
|
-
yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagOffset + node.tag.length,
|
|
206
|
+
yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagOffset + node.tag.length, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
|
|
205
207
|
yield `)${utils_1.endOfLine}`;
|
|
206
208
|
yield* generateFailedPropExps(options, ctx, failedPropExps);
|
|
207
209
|
yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
|
|
@@ -227,7 +229,7 @@ function* generateElement(options, ctx, node) {
|
|
|
227
229
|
}
|
|
228
230
|
function* generateFailedPropExps(options, ctx, failedPropExps) {
|
|
229
231
|
for (const failedExp of failedPropExps) {
|
|
230
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template',
|
|
232
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, failedExp.node.loc.source, failedExp.node.loc.start.offset, failedExp.prefix, failedExp.suffix);
|
|
231
233
|
yield utils_1.endOfLine;
|
|
232
234
|
}
|
|
233
235
|
}
|
|
@@ -260,11 +262,11 @@ function* generateCanonicalComponentName(tagText, offset, features) {
|
|
|
260
262
|
function* generateComponentGeneric(ctx) {
|
|
261
263
|
if (ctx.currentInfo.generic) {
|
|
262
264
|
const { content, offset } = ctx.currentInfo.generic;
|
|
263
|
-
yield* (0, wrapWith_1.wrapWith)(offset, offset + content.length,
|
|
265
|
+
yield* (0, wrapWith_1.wrapWith)(offset, offset + content.length, codeFeatures_1.codeFeatures.verification, `<`, [
|
|
264
266
|
content,
|
|
265
267
|
'template',
|
|
266
268
|
offset,
|
|
267
|
-
|
|
269
|
+
codeFeatures_1.codeFeatures.all,
|
|
268
270
|
], `>`);
|
|
269
271
|
}
|
|
270
272
|
}
|
|
@@ -276,7 +278,7 @@ function* generateElementReference(options, ctx, node) {
|
|
|
276
278
|
const [content, startOffset] = (0, utils_1.normalizeAttributeValue)(prop.value);
|
|
277
279
|
// navigation support for `const foo = ref()`
|
|
278
280
|
yield `/** @type {typeof __VLS_ctx`;
|
|
279
|
-
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset,
|
|
281
|
+
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, startOffset, codeFeatures_1.codeFeatures.navigation);
|
|
280
282
|
yield `} */${utils_1.endOfLine}`;
|
|
281
283
|
if (utils_1.identifierRegex.test(content) && !options.templateRefNames.has(content)) {
|
|
282
284
|
ctx.accessExternalVariable(content, startOffset);
|
|
@@ -30,16 +30,16 @@ function* generateElementDirectives(options, ctx, node) {
|
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
ctx.accessExternalVariable((0, shared_1.camelize)('v-' + prop.name), prop.loc.start.offset);
|
|
33
|
-
yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset,
|
|
33
|
+
yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, codeFeatures_1.codeFeatures.verification, `__VLS_asFunctionalDirective(`, ...generateIdentifier(options, prop), `)(null!, { ...__VLS_directiveBindingRestFields, `, ...generateArg(options, ctx, prop), ...generateModifiers(options, ctx, prop), ...generateValue(options, ctx, prop), ` }, null!, null!)`);
|
|
34
34
|
yield utils_1.endOfLine;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function* generateIdentifier(options,
|
|
37
|
+
function* generateIdentifier(options, prop) {
|
|
38
38
|
const rawName = 'v-' + prop.name;
|
|
39
|
-
yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + rawName.length,
|
|
39
|
+
yield* (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + rawName.length, codeFeatures_1.codeFeatures.verification, `__VLS_directives.`, ...(0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, {
|
|
40
40
|
...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
|
|
41
41
|
verification: options.vueCompilerOptions.checkUnknownDirectives && !builtInDirectives.has(prop.name),
|
|
42
|
-
}))
|
|
42
|
+
}));
|
|
43
43
|
}
|
|
44
44
|
function* generateArg(options, ctx, prop) {
|
|
45
45
|
const { arg } = prop;
|
|
@@ -47,13 +47,13 @@ function* generateArg(options, ctx, prop) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const startOffset = arg.loc.start.offset + arg.loc.source.indexOf(arg.content);
|
|
50
|
-
yield* (0, wrapWith_1.wrapWith)(startOffset, startOffset + arg.content.length,
|
|
50
|
+
yield* (0, wrapWith_1.wrapWith)(startOffset, startOffset + arg.content.length, codeFeatures_1.codeFeatures.verification, `arg`);
|
|
51
51
|
yield `: `;
|
|
52
52
|
if (arg.isStatic) {
|
|
53
|
-
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset,
|
|
53
|
+
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, codeFeatures_1.codeFeatures.all);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template',
|
|
56
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, arg.content, startOffset, `(`, `)`);
|
|
57
57
|
}
|
|
58
58
|
yield `, `;
|
|
59
59
|
}
|
|
@@ -64,10 +64,10 @@ function* generateModifiers(options, ctx, prop, propertyName = 'modifiers') {
|
|
|
64
64
|
}
|
|
65
65
|
const startOffset = modifiers[0].loc.start.offset - 1;
|
|
66
66
|
const endOffset = modifiers.at(-1).loc.end.offset;
|
|
67
|
-
yield* (0, wrapWith_1.wrapWith)(startOffset, endOffset,
|
|
67
|
+
yield* (0, wrapWith_1.wrapWith)(startOffset, endOffset, codeFeatures_1.codeFeatures.verification, propertyName);
|
|
68
68
|
yield `: { `;
|
|
69
69
|
for (const mod of modifiers) {
|
|
70
|
-
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset,
|
|
70
|
+
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlight);
|
|
71
71
|
yield `: true, `;
|
|
72
72
|
}
|
|
73
73
|
yield `}, `;
|
|
@@ -77,7 +77,7 @@ function* generateValue(options, ctx, prop) {
|
|
|
77
77
|
if (exp?.type !== CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset,
|
|
80
|
+
yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification, `value`);
|
|
81
81
|
yield `: `;
|
|
82
82
|
yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
|
|
83
83
|
}
|
|
@@ -4,7 +4,7 @@ import type { Code, VueCodeInformation } from '../../types';
|
|
|
4
4
|
import type { TemplateCodegenContext } from './context';
|
|
5
5
|
import type { TemplateCodegenOptions } from './index';
|
|
6
6
|
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentOriginalVar: string, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
|
|
7
|
-
export declare function generateEventArg(
|
|
7
|
+
export declare function generateEventArg(options: TemplateCodegenOptions, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>;
|
|
8
8
|
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
9
9
|
export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
10
10
|
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean;
|