Skip to content
Source
Sign inSign up
TanStack/router

Generated d.ts files for ESM don’t have file extensions #1087

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

Describe the bug

When having moduleResolution set to node16 typescript complains about missing named exports when trying to import e.g. createRouter via import { createRouter } from '@tanstack/react-router'. When I navigate to the source of @tanstack/react-router I end up in node_modules/@tanstack/react-router/dist/esm/index.d.ts every export * from './*' statement is flagged as an error typescript: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './awaited.js'? [2835]. When I look into the js file (node_modules/@tanstack/react-router/dist/esm/index.js) everything looks fine and all file extensions are present, so it works fine in nodejs but still typescript complains because the .d.ts file is different as the .js file.

Your Example Website or App

https://stackblitz.com/edit/github-yk78pg

Steps to Reproduce the Bug or Issue

  1. set moduleResolution set to node16
  2. import something from '@tanstack/react-router'
  3. run typescript

Expected behavior

I would expect the file extensions in the .d.ts file to be present.

Screenshots or Videos

No response

Platform

  • OS: macos
  • Browser: n/a
  • Version: 1.12.12

Additional context

No response

  1. can you set moduleResolution to Bundler instead?

  2. can you set moduleResolution to Bundler instead?

    As a temporary workaround yes, but in the long-run no. Because this would allow other imports (e.g. imports to local files) without file extensions to pass the typescript check but would fail at runtime when running in node.

  3. lachlancollins(GitHub profile, opens in a new tab) assignedlachlancollins

  4. Hi @lo1tuma , thanks for reporting this - a fix is incoming. That stackblitz is using a beta version of @tanstack/react-router, but the issue still exists in recent versions.

Sign in to join this conversation.