Skip to content
Source
Sign inSign up
TanStack/ai

[ai-harness][ai] Published .d.ts files import bare directories ('..', '../..'), unresolvable under nodenext #2173

Send to my agent
Openviclafouch(GitHub profile, opens in a new tab) opened this issue 0 comments

TanStack AI version

@tanstack/ai@1.4.0, @tanstack/ai-harness@0.3.0

Framework/Library version

TypeScript 7.0.2, Node.js 26, "module": "nodenext"

Describe the bug and the steps to reproduce it

The published .d.ts files import bare directories in inline type imports, such as import('..').ExtensionPoint<PermissionRule> in ai-harness/dist/esm/first-party/permissions.d.ts. Node resolution (nodenext) does not resolve a directory specifier, and with skipLibCheck the type silently becomes any.

package.json:

{ "type": "module" }

tsconfig.json:

{ "compilerOptions": { "module": "nodenext", "strict": true, "noEmit": true, "skipLibCheck": true, "types": [] } }

index.ts:

import { definePlugin, PermissionRules } from '@tanstack/ai-harness'

definePlugin({
  name: 'repro',
  setup: (ctx) => {
    const rules = ctx.collect(PermissionRules)
    const check: ReadonlyArray<{ tool: string }> = rules
    return {}
  }
})
index.ts(7,11): error TS2322: Type 'readonly unknown[]' is not assignable to type 'readonly { tool: string; }[]'.

It passes under --module preserve --moduleResolution bundler. With --skipLibCheck false, tsc names the cause:

ai-harness/dist/esm/first-party/permissions.d.ts(20,46): error TS2307: Cannot find module '..' or its corresponding type declarations.

Affected files:

  • @tanstack/ai-harness@0.3.0: 18 files under dist/esm/first-party/ and dist/esm/session/, with import('..') and import('../..').
  • @tanstack/ai@1.4.0: utilities/sanitize-unicode.d.ts (import('..')) and activities/chat/agents/spawn.d.ts (import('../../..')).

The source never writes these specifiers. The declaration emitter picks the shortest one that the repo's Bundler resolution accepts. The guardrail added in #924 (scripts/scan-dangling-dts.mjs) matches only specifiers with a slash after the dots (/(?:from|import)\s*\(?\s*['"](\.\.?\/[^'"]+)['"]/), so bare '.', '..' and '../..' pass through.

Rewriting each bare specifier to its index.js (import('../index.js'), import('../../index.js')) fixes it, which we apply today as a pnpm patch.

A possible fix: emit declarations under nodenext resolution, or annotate the exports involved, and widen the scan to bare relative specifiers.

The three files above, with npm i @tanstack/ai-harness@0.3.0 @tanstack/ai@1.4.0 typescript@7.0.2 zod @opentelemetry/api and npx tsc -p ..

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. tanstack-source added labelsbug

  2. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

Sign in to join this conversation.