test(typescript): pin the type-alias capture to a tag that maps to a label

The capture test asserted `@declaration.type`, the tag that
`normalizeNodeLabel` does not recognize (it accepts typealias / type_alias and
has no "type" case). So the test passed for as long as the tag was broken: it
checked only that the capture FIRED, never that it resolved to anything, while
TypeScript aliases produced no scope-resolution def at all.

Updated to the working tag and given a second assertion that the derived kind
string is one the label mapper accepts — the property that actually matters,
and the one whose absence let a dead tag sit pinned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ReidenXerx 2026-08-06 14:35:12 +03:00
parent 1320cc6db3
commit 35f58305b9

View file

@ -142,12 +142,32 @@ describe('emitTsScopeCaptures — declarations', () => {
expect(m!['@declaration.name'].text).toBe('Status');
});
it('captures type-alias declarations under @declaration.type', () => {
const m = findMatch('type ID = string;', (t) => t.includes('@declaration.type'));
// The tag is `@declaration.type_alias`, matching Kotlin and Dart. It was
// `@declaration.type`, which `normalizeNodeLabel` does not recognize — it
// accepts `typealias` / `type_alias` and has no `type` case — so the capture
// fired but mapped to NO label and TypeScript aliases produced no
// scope-resolution def at all. This test passed the whole time because it
// asserted only that the capture existed, never that it resolved to
// anything; the label assertion below is what stops a dead tag being pinned
// again.
it('captures type-alias declarations under @declaration.type_alias', () => {
const m = findMatch('type ID = string;', (t) => t.includes('@declaration.type_alias'));
expect(m).toBeDefined();
expect(m!['@declaration.name'].text).toBe('ID');
});
it('maps the type-alias capture to a real NodeLabel', () => {
const m = findMatch('type ID = string;', (t) => t.includes('@declaration.type_alias'));
const anchor = Object.keys(m!).find(
(k) => k.startsWith('@declaration.') && k !== '@declaration.name',
);
expect(anchor).toBeDefined();
// The kind string the extractor derives from the anchor must be one
// `normalizeNodeLabel` accepts, or the declaration silently vanishes.
const kind = anchor!.slice('@declaration.'.length);
expect(['typealias', 'type_alias']).toContain(kind);
});
it('captures namespace declarations under @declaration.namespace', () => {
const m = findMatch('namespace NS { class A {} }', (t) => t.includes('@declaration.namespace'));
expect(m).toBeDefined();