Skip to content

Commit f825668

Browse files
committed
feat: non-capturing meta variable
1 parent e9158c3 commit f825668

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/matchers/src/template.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ function parseTemplate(
7575
}
7676

7777
if (isMetaVariable(node)) {
78-
schemas.push(capture(node.name.slice(1)));
78+
if (node.name.startsWith('$_')) {
79+
schemas.push(any);
80+
} else {
81+
schemas.push(capture(node.name.slice(1)));
82+
}
7983
node.name = `$${schemaIndex++}`;
8084
}
8185

packages/matchers/test/template.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ test('template with meta variable syntax', () => {
4040
greeting: { value: 'hello' },
4141
});
4242
});
43+
44+
test('template with non-capturing meta variable syntax', () => {
45+
const schema = m.expression`$_method($_arg)`;
46+
const matcher = m.compile(schema);
47+
console.log(matcher.toString());
48+
49+
expect(matcher(parseExpression('print(1)'))).not.toHaveProperty('_method');
50+
});

0 commit comments

Comments
 (0)