types: move scopeIds into PrefixMeta
This commit is contained in:
parent
f15528350e
commit
b68eb229c7
@ -63,6 +63,7 @@ interface PrefixMeta {
|
|||||||
prefix?: string
|
prefix?: string
|
||||||
start: number
|
start: number
|
||||||
end: number
|
end: number
|
||||||
|
scopeIds?: Set<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important: since this function uses Node.js only dependencies, it should
|
// Important: since this function uses Node.js only dependencies, it should
|
||||||
@ -145,10 +146,7 @@ export function processExpression(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const { name } = child
|
const { name } = child
|
||||||
if (
|
if (node.scopeIds && node.scopeIds.has(name)) {
|
||||||
(node as any)._scopeIds &&
|
|
||||||
(node as any)._scopeIds.has(name)
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (name in knownIds) {
|
if (name in knownIds) {
|
||||||
@ -156,19 +154,16 @@ export function processExpression(
|
|||||||
} else {
|
} else {
|
||||||
knownIds[name] = 1
|
knownIds[name] = 1
|
||||||
}
|
}
|
||||||
;(
|
;(node.scopeIds || (node.scopeIds = new Set())).add(name)
|
||||||
(node as any)._scopeIds ||
|
|
||||||
((node as any)._scopeIds = new Set())
|
|
||||||
).add(name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leave(node: any) {
|
leave(node: Node & PrefixMeta) {
|
||||||
if (node !== ast.body[0].expression && node._scopeIds) {
|
if (node !== ast.body[0].expression && node.scopeIds) {
|
||||||
node._scopeIds.forEach((id: string) => {
|
node.scopeIds.forEach((id: string) => {
|
||||||
knownIds[id]--
|
knownIds[id]--
|
||||||
if (knownIds[id] === 0) {
|
if (knownIds[id] === 0) {
|
||||||
delete knownIds[id]
|
delete knownIds[id]
|
||||||
|
Loading…
Reference in New Issue
Block a user