@tanstack/svelte-devtools: published declarations omit .js extension on ./types imports, breaking node16/nodenext

未關閉 適合新手
#564 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@dirgaydtm 已經在處理了。

開始於 2026年11月17日。

  • #565 來自 @dirgaydtm —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
85/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

閱讀 issue 中提到的三個原始碼進入點:packages/svelte-devtools/src/index.ts、TanStackDevtools.svelte 和 devtools.ts。按照說明更新它們對 ./types 的相對匯入,接著建置 package,並在停用 skipLibCheck 的情況下使用 NodeNext 或 Node16 解析方式檢查宣告檔;當宣告檔能夠解析且回報的 TS2835 錯誤消失時,即完成。

由索引模型根據 Issue 內容生成。

描述

TanStack Devtools version

@tanstack/[email protected] (also main at 8f62544)

Framework/Library version

[email protected], [email protected], [email protected] and [email protected]

Describe the bug and the steps to reproduce it

@tanstack/svelte-devtools sets "type": "module" and builds with svelte-package, which preserves relative import specifiers verbatim in dist/esm/. Three files import ./types without a .js extension:

  • dist/esm/index.d.ts: export type { TanStackDevtoolsSveltePlugin, TanStackDevtoolsSvelteInit, } from './types';
  • dist/esm/TanStackDevtools.svelte.d.ts (and TanStackDevtools.svelte): import type { TanStackDevtoolsSvelteInit } from './types';
  • dist/esm/devtools.d.ts: import type { TanStackDevtoolsSvelteInit } from './types';

Under moduleResolution: "NodeNext" or "Node16" (which SvelteKit's packaging docs recommend for Svelte libraries), TypeScript requires explicit .js extensions on relative imports in ESM declarations. With skipLibCheck: true, ./types fails to resolve and both <TanStackDevtools /> props and the exported TanStackDevtoolsSveltePlugin / TanStackDevtoolsSvelteInit types silently degrade to any. With skipLibCheck: false, svelte-check and tsc fail with TS2835.

Steps to reproduce:

npm init -y
npm i @tanstack/[email protected] [email protected] [email protected] [email protected]
<!-- src/App.svelte -->
<script lang="ts">
  import {
    TanStackDevtools,
    type TanStackDevtoolsSveltePlugin,
  } from "@tanstack/svelte-devtools";

  const badPlugin: TanStackDevtoolsSveltePlugin = 123;
</script>

<TanStackDevtools config={{ openHotkey: 123 }} plugins={[badPlugin]} />
{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "target": "ES2022",
    "strict": true,
    "skipLibCheck": true,
    "types": ["svelte"]
  },
  "include": ["src/**/*"]
}

Running npx svelte-check --tsconfig ./tsconfig.json reports:

svelte-check found 0 errors and 0 warnings

With "skipLibCheck": false, npx svelte-check --tsconfig ./tsconfig.json fails inside @tanstack/svelte-devtools (and tsc --noEmit --module nodenext --moduleResolution nodenext --skipLibCheck false reports the same TS2835 on index.d.ts under TypeScript 6.0.3 and 7.0.2):

node_modules/@tanstack/svelte-devtools/dist/esm/TanStackDevtools.svelte.d.ts:1:49
Error: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './types.js'? 
import type { TanStackDevtoolsSvelteInit } from './types';
declare const TanStackDevtools: import("svelte").Component<TanStackDevtoolsSvelteInit, {}, "">;

node_modules/@tanstack/svelte-devtools/dist/esm/index.d.ts:2:80
Error: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './types.js'? 
export { default as TanStackDevtools } from './TanStackDevtools.svelte';
export type { TanStackDevtoolsSveltePlugin, TanStackDevtoolsSvelteInit, } from './types';

Expected output (matching "module": "ESNext", "moduleResolution": "Bundler"):

src/App.svelte:7:9
Error: Type 'number' is not assignable to type 'TanStackDevtoolsSveltePlugin'. (ts)

src/App.svelte:10:29
Error: Type 'number' is not assignable to type 'KeyboardKey[]'. (ts)

svelte-check found 2 errors and 0 warnings in 1 file

Changing from './types' to from './types.js' in packages/svelte-devtools/src/index.ts, packages/svelte-devtools/src/TanStackDevtools.svelte (which already uses from './devtools.js' on the line above), and packages/svelte-devtools/src/devtools.ts resolves this.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://gist.github.com/trackoor/e88698351ce89d44b8cf5c516d8e7871

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

No, because I do not have time to dig into it

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.

Credit: https://ucsbplse.github.io/

主要語言
TypeScript
星號
514
分支
105
平均合併
11 小時 38 分鐘
30 天內合併 PR
2

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/devtools 的其他 Issue

查看 TanStack/devtools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。