@vue/language-core 1.7.12 → 1.7.14
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/out/generators/script.js +8 -4
- package/out/generators/template.js +11 -36
- package/out/utils/transform.js +27 -14
- package/package.json +4 -4
package/out/generators/script.js
CHANGED
|
@@ -52,7 +52,7 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
52
52
|
const usedHelperTypes = {
|
|
53
53
|
DefinePropsToOptions: false,
|
|
54
54
|
mergePropDefaults: false,
|
|
55
|
-
|
|
55
|
+
EmitsTypeHelpers: false,
|
|
56
56
|
WithTemplateSlots: false,
|
|
57
57
|
PropsChildren: false,
|
|
58
58
|
};
|
|
@@ -101,7 +101,7 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
101
101
|
};\n`);
|
|
102
102
|
usedPrettify = true;
|
|
103
103
|
}
|
|
104
|
-
if (usedHelperTypes.
|
|
104
|
+
if (usedHelperTypes.EmitsTypeHelpers) {
|
|
105
105
|
// fix https://github.com/vuejs/language-tools/issues/926
|
|
106
106
|
codes.push('type __VLS_UnionToIntersection<U> = __VLS_Prettify<(U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never>;\n');
|
|
107
107
|
usedPrettify = true;
|
|
@@ -111,6 +111,10 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
111
111
|
else {
|
|
112
112
|
codes.push(sharedTypes.genConstructorOverloads('__VLS_ConstructorOverloads'));
|
|
113
113
|
}
|
|
114
|
+
codes.push(`type __VLS_NormalizeEmits<T> = __VLS_ConstructorOverloads<T> & {
|
|
115
|
+
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
|
|
116
|
+
}`);
|
|
117
|
+
;
|
|
114
118
|
}
|
|
115
119
|
if (usedHelperTypes.WithTemplateSlots) {
|
|
116
120
|
codes.push(`type __VLS_WithTemplateSlots<T, S> = T & { new(): {\n`, `$slots: S;\n`);
|
|
@@ -506,8 +510,8 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
506
510
|
codes.push(`},\n`);
|
|
507
511
|
}
|
|
508
512
|
if (scriptSetupRanges.emitsTypeArg) {
|
|
509
|
-
usedHelperTypes.
|
|
510
|
-
codes.push(`emits: ({} as __VLS_UnionToIntersection<
|
|
513
|
+
usedHelperTypes.EmitsTypeHelpers = true;
|
|
514
|
+
codes.push(`emits: ({} as __VLS_UnionToIntersection<__VLS_NormalizeEmits<`);
|
|
511
515
|
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.emitsTypeArg.start, scriptSetupRanges.emitsTypeArg.end);
|
|
512
516
|
codes.push(`>>),\n`);
|
|
513
517
|
}
|
|
@@ -298,14 +298,14 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
298
298
|
function visitNode(node, parentEl, prevNode, componentCtxVar) {
|
|
299
299
|
resolveComment();
|
|
300
300
|
if (prevNode?.type === 3 /* CompilerDOM.NodeTypes.COMMENT */) {
|
|
301
|
-
const commentText = prevNode.content.trim();
|
|
302
|
-
if (commentText
|
|
301
|
+
const commentText = prevNode.content.trim().split(' ')[0];
|
|
302
|
+
if (commentText.match(/^@vue-skip\b[\s\S]*/)) {
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
|
-
else if (commentText
|
|
305
|
+
else if (commentText.match(/^@vue-ignore\b[\s\S]*/)) {
|
|
306
306
|
ignoreStart = codes.length;
|
|
307
307
|
}
|
|
308
|
-
else if (commentText
|
|
308
|
+
else if (commentText.match(/^@vue-expect-error\b[\s\S]*/)) {
|
|
309
309
|
expectedErrorStart = codes.length;
|
|
310
310
|
expectedErrorNode = prevNode;
|
|
311
311
|
}
|
|
@@ -907,12 +907,11 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
907
907
|
) {
|
|
908
908
|
continue;
|
|
909
909
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
attrNameText = propName;
|
|
910
|
+
let camelized = false;
|
|
911
|
+
if ((0, shared_1.hyphenate)(prop.name) === prop.name
|
|
912
|
+
&& !vueCompilerOptions.htmlAttributes.some(pattern => (0, minimatch_1.minimatch)(attrNameText, pattern))) {
|
|
913
|
+
attrNameText = (0, shared_1.camelize)(prop.name);
|
|
914
|
+
camelized = true;
|
|
916
915
|
}
|
|
917
916
|
// camelize name
|
|
918
917
|
codes.push([
|
|
@@ -922,14 +921,14 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
922
921
|
caps_diagnosticOnly,
|
|
923
922
|
]);
|
|
924
923
|
codes.push(...createObjectPropertyCode([
|
|
925
|
-
|
|
924
|
+
attrNameText,
|
|
926
925
|
'template',
|
|
927
926
|
[prop.loc.start.offset, prop.loc.start.offset + prop.name.length],
|
|
928
927
|
{
|
|
929
928
|
...caps_attr,
|
|
930
929
|
rename: {
|
|
931
930
|
normalize: shared_1.camelize,
|
|
932
|
-
apply:
|
|
931
|
+
apply: camelized ? shared_1.hyphenate : noEditApply,
|
|
933
932
|
},
|
|
934
933
|
},
|
|
935
934
|
], prop.loc.name_1 ?? (prop.loc.name_1 = {})));
|
|
@@ -948,30 +947,6 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
948
947
|
caps_diagnosticOnly,
|
|
949
948
|
]);
|
|
950
949
|
codes.push(', ');
|
|
951
|
-
// original name
|
|
952
|
-
if (attrNameText !== propName) {
|
|
953
|
-
codes.push(...createObjectPropertyCode([
|
|
954
|
-
attrNameText,
|
|
955
|
-
'template',
|
|
956
|
-
prop.loc.start.offset,
|
|
957
|
-
{
|
|
958
|
-
...caps_attr,
|
|
959
|
-
rename: {
|
|
960
|
-
normalize: shared_1.camelize,
|
|
961
|
-
apply: getRenameApply(prop.name),
|
|
962
|
-
},
|
|
963
|
-
},
|
|
964
|
-
], prop.loc.name_2 ?? (prop.loc.name_2 = {})));
|
|
965
|
-
codes.push(': (');
|
|
966
|
-
if (prop.value) {
|
|
967
|
-
generateAttrValue(prop.value);
|
|
968
|
-
}
|
|
969
|
-
else {
|
|
970
|
-
codes.push('true');
|
|
971
|
-
}
|
|
972
|
-
codes.push(')');
|
|
973
|
-
codes.push(', ');
|
|
974
|
-
}
|
|
975
950
|
}
|
|
976
951
|
else if (prop.type === 7 /* CompilerDOM.NodeTypes.DIRECTIVE */
|
|
977
952
|
&& prop.name === 'bind'
|
package/out/utils/transform.js
CHANGED
|
@@ -88,8 +88,7 @@ function walkInterpolationFragment(ts, code, ast, cb, localVars, identifiers, vu
|
|
|
88
88
|
return ctxVars;
|
|
89
89
|
}
|
|
90
90
|
exports.walkInterpolationFragment = walkInterpolationFragment;
|
|
91
|
-
function walkIdentifiers(ts, node, cb, localVars) {
|
|
92
|
-
const blockVars = [];
|
|
91
|
+
function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true) {
|
|
93
92
|
if (ts.isIdentifier(node)) {
|
|
94
93
|
cb(node, false);
|
|
95
94
|
}
|
|
@@ -97,26 +96,27 @@ function walkIdentifiers(ts, node, cb, localVars) {
|
|
|
97
96
|
cb(node.name, true);
|
|
98
97
|
}
|
|
99
98
|
else if (ts.isPropertyAccessExpression(node)) {
|
|
100
|
-
walkIdentifiers(ts, node.expression, cb, localVars);
|
|
99
|
+
walkIdentifiers(ts, node.expression, cb, localVars, blockVars, false);
|
|
101
100
|
}
|
|
102
101
|
else if (ts.isVariableDeclaration(node)) {
|
|
103
102
|
colletVars(ts, node.name, blockVars);
|
|
104
|
-
for (const varName of blockVars)
|
|
103
|
+
for (const varName of blockVars) {
|
|
105
104
|
localVars[varName] = (localVars[varName] ?? 0) + 1;
|
|
105
|
+
}
|
|
106
106
|
if (node.initializer)
|
|
107
|
-
walkIdentifiers(ts, node.initializer, cb, localVars);
|
|
107
|
+
walkIdentifiers(ts, node.initializer, cb, localVars, blockVars, false);
|
|
108
108
|
}
|
|
109
109
|
else if (ts.isArrowFunction(node)) {
|
|
110
110
|
const functionArgs = [];
|
|
111
111
|
for (const param of node.parameters) {
|
|
112
112
|
colletVars(ts, param.name, functionArgs);
|
|
113
113
|
if (param.type) {
|
|
114
|
-
walkIdentifiers(ts, param.type, cb, localVars);
|
|
114
|
+
walkIdentifiers(ts, param.type, cb, localVars, blockVars, false);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
for (const varName of functionArgs)
|
|
118
118
|
localVars[varName] = (localVars[varName] ?? 0) + 1;
|
|
119
|
-
walkIdentifiers(ts, node.body, cb, localVars);
|
|
119
|
+
walkIdentifiers(ts, node.body, cb, localVars, blockVars, false);
|
|
120
120
|
for (const varName of functionArgs)
|
|
121
121
|
localVars[varName]--;
|
|
122
122
|
}
|
|
@@ -125,18 +125,18 @@ function walkIdentifiers(ts, node, cb, localVars) {
|
|
|
125
125
|
if (ts.isPropertyAssignment(prop)) {
|
|
126
126
|
// fix https://github.com/vuejs/language-tools/issues/1176
|
|
127
127
|
if (ts.isComputedPropertyName(prop.name)) {
|
|
128
|
-
walkIdentifiers(ts, prop.name.expression, cb, localVars);
|
|
128
|
+
walkIdentifiers(ts, prop.name.expression, cb, localVars, blockVars, false);
|
|
129
129
|
}
|
|
130
|
-
walkIdentifiers(ts, prop.initializer, cb, localVars);
|
|
130
|
+
walkIdentifiers(ts, prop.initializer, cb, localVars, blockVars, false);
|
|
131
131
|
}
|
|
132
132
|
// fix https://github.com/vuejs/language-tools/issues/1156
|
|
133
133
|
else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
134
|
-
walkIdentifiers(ts, prop, cb, localVars);
|
|
134
|
+
walkIdentifiers(ts, prop, cb, localVars, blockVars, false);
|
|
135
135
|
}
|
|
136
136
|
// fix https://github.com/vuejs/language-tools/issues/1148#issuecomment-1094378126
|
|
137
137
|
else if (ts.isSpreadAssignment(prop)) {
|
|
138
138
|
// TODO: cannot report "Spread types may only be created from object types.ts(2698)"
|
|
139
|
-
walkIdentifiers(ts, prop.expression, cb, localVars);
|
|
139
|
+
walkIdentifiers(ts, prop.expression, cb, localVars, blockVars, false);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -145,10 +145,23 @@ function walkIdentifiers(ts, node, cb, localVars) {
|
|
|
145
145
|
node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
|
|
148
|
+
const _blockVars = blockVars;
|
|
149
|
+
if (ts.isBlock(node)) {
|
|
150
|
+
blockVars = [];
|
|
151
|
+
}
|
|
152
|
+
node.forEachChild(node => walkIdentifiers(ts, node, cb, localVars, blockVars, false));
|
|
153
|
+
if (ts.isBlock(node)) {
|
|
154
|
+
for (const varName of blockVars) {
|
|
155
|
+
localVars[varName]--;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
blockVars = _blockVars;
|
|
159
|
+
}
|
|
160
|
+
if (isRoot) {
|
|
161
|
+
for (const varName of blockVars) {
|
|
162
|
+
localVars[varName]--;
|
|
163
|
+
}
|
|
149
164
|
}
|
|
150
|
-
for (const varName of blockVars)
|
|
151
|
-
localVars[varName]--;
|
|
152
165
|
}
|
|
153
166
|
function walkIdentifiersInTypeReference(ts, node, cb) {
|
|
154
167
|
if (ts.isTypeQueryNode(node) && ts.isIdentifier(node.exprName)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.14",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/vue-language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.7.
|
|
17
|
-
"@volar/source-map": "1.7.
|
|
16
|
+
"@volar/language-core": "1.7.6",
|
|
17
|
+
"@volar/source-map": "1.7.6",
|
|
18
18
|
"@vue/compiler-dom": "^3.3.0",
|
|
19
19
|
"@vue/reactivity": "^3.3.0",
|
|
20
20
|
"@vue/shared": "^3.3.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a8a05a278ab807590faeafdfd76646f5c41c0443"
|
|
38
38
|
}
|