@tanstack/svelte-devtools: published declarations omit .js extension on ./types imports, breaking node16/nodenext
評估
- 難度
- 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(andTanStackDevtools.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
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/devtools 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 5/5 一週以上 新手友好度 25/100
-
devtools-vite: four transform hooks have no filter, and inject-plugin parses pre-bundled dependency chunks可能已有人在做 @shkumbinhasani 於 30 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 38/100
-
難度 2/5 1-3 小時 新手友好度 52/100
-
難度 3/5 1-2 天 新手友好度 68/100
查看 TanStack/devtools 的全部 Issue
相似的 Issue
-
bot:ai-assisted component:platform-js status:untriaged
難度 1/5 1 小時以內 新手友好度 74/100
midnightntwrk/platform-js#38 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
ranxianglei/billion-context#7068 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
mybigday/whisper.rn#348 ·
-
enhancement severity:low
難度 2/5 1-3 小時 新手友好度 82/100
Battle-Cattle/BCUK-Bot-4#1075 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
ilan-pinto/roaring-lions#1552 ·
維護者通常 1 天內回覆