Skip to content

TypeScript: a generic type argument on a tagged template (db<Row[]>SELECT …) yields a parse ERROR node #1975

Description

@dazaiio

Version

codebase-memory-mcp 0.10.8

Platform

macOS (Apple Silicon)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

A tagged template with an explicit type argument — tag — is reported in parse_partial and the whole expression becomes an ERROR node, so no CALLS edge to the tag is produced and nothing nested inside the ${…} interpolations is indexed. The same call resolves fine without the type argument, and with a normal (non-template) call.

This is valid TypeScript (TaggedTemplateExpression with typeArguments, TS 4.x+) and is the standard form for typed SQL template tags such as postgres.js, slonik and @vercel/postgres.

Expected: tag parses and produces the same edges as tag.

Impact on one repository: 696 call sites in 136 files, which is 132 of its 255 parse_partial entries.

Reproduction

  1. Code — three dummy files under /tmp/repro, one construct each:

a-generic-tagged.ts — fails

type Row = { id: string }
declare const db: any
export async function withGeneric(): Promise<Row[]> {
  const rows = await db<Row[]>`SELECT id FROM widgets`
  return rows
}

b-plain-tagged.ts — fine

declare const db: any
export async function withoutGeneric() {
  const rows = await db`SELECT id FROM widgets`
  return rows
}

c-generic-call.ts — fine

type Row = { id: string }
declare const db: any
export async function withGenericCall() {
  const rows = await db<Row[]>('SELECT id FROM widgets')
  return rows
}
  1. Command:

codebase-memory-mcp cli index_repository '{"repo_path":"/tmp/repro","mode":"full","name":"repro"}'

  1. Result:

parse_partial: 1
{'path': 'a-generic-tagged.ts', 'error_ranges': '4-4'}

Only the generic-tagged-template file is affected. Expected: no partial parses.

Lost edges, shown with a real tag function (export function db<T>(strings: TemplateStringsArray, ...values: unknown[]): T) called both ways from the same module:

MATCH (a)-[:CALLS]->(b) RETURN a.qualified_name AS caller, b.qualified_name AS callee
repro.uses.plain -> repro.lib.db <- plain tagged template
total: 1

The generic() -> db edge is missing.

Logs

parse_partial: 1
  {'path': 'a-generic-tagged.ts', 'error_ranges': '4-4'}

Diagnostics trajectory (memory / performance / leak issues)


Project scale (if relevant)

27,757 nodes / 86,358 edges / ~1,900 files

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions