@vue/language-core
Advanced tools
Comparing version 1.7.12 to 1.7.13
@@ -55,3 +55,3 @@ "use strict"; | ||
mergePropDefaults: false, | ||
ConstructorOverloads: false, | ||
EmitsTypeHelpers: false, | ||
WithTemplateSlots: false, | ||
@@ -105,3 +105,3 @@ PropsChildren: false, | ||
} | ||
if (usedHelperTypes.ConstructorOverloads) { | ||
if (usedHelperTypes.EmitsTypeHelpers) { | ||
// fix https://github.com/vuejs/language-tools/issues/926 | ||
@@ -116,2 +116,6 @@ codes.push('type __VLS_UnionToIntersection<U> = __VLS_Prettify<(U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never>;\n'); | ||
} | ||
codes.push(`type __VLS_NormalizeEmits<T> = __VLS_ConstructorOverloads<T> & { | ||
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never | ||
}`); | ||
; | ||
} | ||
@@ -512,4 +516,4 @@ if (usedHelperTypes.WithTemplateSlots) { | ||
if (scriptSetupRanges.emitsTypeArg) { | ||
usedHelperTypes.ConstructorOverloads = true; | ||
codes.push(`emits: ({} as __VLS_UnionToIntersection<__VLS_ConstructorOverloads<`); | ||
usedHelperTypes.EmitsTypeHelpers = true; | ||
codes.push(`emits: ({} as __VLS_UnionToIntersection<__VLS_NormalizeEmits<`); | ||
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.emitsTypeArg.start, scriptSetupRanges.emitsTypeArg.end); | ||
@@ -516,0 +520,0 @@ codes.push(`>>),\n`); |
@@ -91,4 +91,3 @@ "use strict"; | ||
exports.walkInterpolationFragment = walkInterpolationFragment; | ||
function walkIdentifiers(ts, node, cb, localVars) { | ||
const blockVars = []; | ||
function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true) { | ||
if (ts.isIdentifier(node)) { | ||
@@ -101,10 +100,11 @@ cb(node, false); | ||
else if (ts.isPropertyAccessExpression(node)) { | ||
walkIdentifiers(ts, node.expression, cb, localVars); | ||
walkIdentifiers(ts, node.expression, cb, localVars, blockVars, false); | ||
} | ||
else if (ts.isVariableDeclaration(node)) { | ||
colletVars(ts, node.name, blockVars); | ||
for (const varName of blockVars) | ||
for (const varName of blockVars) { | ||
localVars[varName] = (localVars[varName] ?? 0) + 1; | ||
} | ||
if (node.initializer) | ||
walkIdentifiers(ts, node.initializer, cb, localVars); | ||
walkIdentifiers(ts, node.initializer, cb, localVars, blockVars, false); | ||
} | ||
@@ -116,3 +116,3 @@ else if (ts.isArrowFunction(node)) { | ||
if (param.type) { | ||
walkIdentifiers(ts, param.type, cb, localVars); | ||
walkIdentifiers(ts, param.type, cb, localVars, blockVars, false); | ||
} | ||
@@ -122,3 +122,3 @@ } | ||
localVars[varName] = (localVars[varName] ?? 0) + 1; | ||
walkIdentifiers(ts, node.body, cb, localVars); | ||
walkIdentifiers(ts, node.body, cb, localVars, blockVars, false); | ||
for (const varName of functionArgs) | ||
@@ -132,9 +132,9 @@ localVars[varName]--; | ||
if (ts.isComputedPropertyName(prop.name)) { | ||
walkIdentifiers(ts, prop.name.expression, cb, localVars); | ||
walkIdentifiers(ts, prop.name.expression, cb, localVars, blockVars, false); | ||
} | ||
walkIdentifiers(ts, prop.initializer, cb, localVars); | ||
walkIdentifiers(ts, prop.initializer, cb, localVars, blockVars, false); | ||
} | ||
// fix https://github.com/vuejs/language-tools/issues/1156 | ||
else if (ts.isShorthandPropertyAssignment(prop)) { | ||
walkIdentifiers(ts, prop, cb, localVars); | ||
walkIdentifiers(ts, prop, cb, localVars, blockVars, false); | ||
} | ||
@@ -144,3 +144,3 @@ // fix https://github.com/vuejs/language-tools/issues/1148#issuecomment-1094378126 | ||
// TODO: cannot report "Spread types may only be created from object types.ts(2698)" | ||
walkIdentifiers(ts, prop.expression, cb, localVars); | ||
walkIdentifiers(ts, prop.expression, cb, localVars, blockVars, false); | ||
} | ||
@@ -154,6 +154,19 @@ } | ||
else { | ||
node.forEachChild(node => walkIdentifiers(ts, node, cb, localVars)); | ||
const _blockVars = blockVars; | ||
if (ts.isBlock(node)) { | ||
blockVars = []; | ||
} | ||
node.forEachChild(node => walkIdentifiers(ts, node, cb, localVars, blockVars, false)); | ||
if (ts.isBlock(node)) { | ||
for (const varName of blockVars) { | ||
localVars[varName]--; | ||
} | ||
} | ||
blockVars = _blockVars; | ||
} | ||
for (const varName of blockVars) | ||
localVars[varName]--; | ||
if (isRoot) { | ||
for (const varName of blockVars) { | ||
localVars[varName]--; | ||
} | ||
} | ||
} | ||
@@ -160,0 +173,0 @@ function walkIdentifiersInTypeReference(ts, node, cb) { |
{ | ||
"name": "@vue/language-core", | ||
"version": "1.7.12", | ||
"version": "1.7.13", | ||
"main": "out/index.js", | ||
@@ -16,4 +16,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/language-core": "1.7.4", | ||
"@volar/source-map": "1.7.4", | ||
"@volar/language-core": "1.7.5", | ||
"@volar/source-map": "1.7.5", | ||
"@vue/compiler-dom": "^3.3.0", | ||
@@ -38,3 +38,3 @@ "@vue/reactivity": "^3.3.0", | ||
}, | ||
"gitHead": "9e712c2d603c690cd03502f5ec1a99bd80b800ac" | ||
"gitHead": "32d5d5e4414f97b0dc28cd727a9cecf60acd4e97" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236186
5163
+ Added@volar/language-core@1.7.5(transitive)
+ Added@volar/source-map@1.7.5(transitive)
- Removed@volar/language-core@1.7.4(transitive)
- Removed@volar/source-map@1.7.4(transitive)
Updated@volar/language-core@1.7.5
Updated@volar/source-map@1.7.5