From 35f58305b9391c14779ab12ebc6dec56906ccc48 Mon Sep 17 00:00:00 2001 From: ReidenXerx Date: Thu, 6 Aug 2026 14:35:12 +0300 Subject: [PATCH] test(typescript): pin the type-alias capture to a tag that maps to a label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../typescript/typescript-captures.test.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gitnexus/test/unit/scope-resolution/typescript/typescript-captures.test.ts b/gitnexus/test/unit/scope-resolution/typescript/typescript-captures.test.ts index c97d41e19..fe9acfb3f 100644 --- a/gitnexus/test/unit/scope-resolution/typescript/typescript-captures.test.ts +++ b/gitnexus/test/unit/scope-resolution/typescript/typescript-captures.test.ts @@ -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();