-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
tsquery/src/matchers/attribute.ts
Lines 39 to 53 in a81e093
| function equal (obj: any, value: any, type: TSQueryAttributeOperatorType): boolean { | |
| switch (type) { | |
| case 'regexp': return typeof obj === 'string' && (value as RegExp).test(obj); | |
| case 'literal': return `${value}` === `${obj}`; | |
| case 'type': return value === typeof obj; | |
| } | |
| } | |
| function notEqual (obj: any, value: any, type: TSQueryAttributeOperatorType): boolean { | |
| switch (type) { | |
| case 'regexp': return typeof obj === 'string' && !(value as RegExp).test(obj); | |
| case 'literal': return `${value}` !== `${obj}`; | |
| case 'type': return value !== typeof obj; | |
| } | |
| } |
unlike esquery they dont have any type info, tsquery could be more type infered, for example, with code
const routeMap = [{}]
we could do somethings like:
VariableDeclaration[name.name="routeMap"][initializer=type(ArrayLiteralExpression)]
which is more accurate than some thing
VariableDeclaration[name.name="routeMap"]):has(ArrayLiteralExpression)
Metadata
Metadata
Assignees
Labels
No labels