@tanstack/svelte-devtools: published declarations omit .js extension on ./types imports, breaking node16/nodenext
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
Đọc ba điểm đầu vào mã nguồn được nêu trong issue: packages/svelte-devtools/src/index.ts, TanStackDevtools.svelte và devtools.ts. Cập nhật các import tương đối của ./types theo mô tả, sau đó build package và kiểm tra các declaration với cơ chế phân giải NodeNext hoặc Node16 khi tắt skipLibCheck; hoàn tất khi các declaration được phân giải và các lỗi TS2835 được báo cáo đã biến mất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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/
- Ngôn ngữ chính
- TypeScript
- Star
- 514
- Fork
- 105
- Merge trung bình
- 11 giờ 38 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/devtools
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
devtools-vite: four transform hooks have no filter, and inject-plugin parses pre-bundled dependency chunksCó thể đã có người làm @shkumbinhasani đã nhận 29 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Tất cả issue của TanStack/devtools
Issue tương tự
-
Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
OpenNSW/nsw-srilanka#1259 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oxc-project/tsrs#1010 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Fission-AI/OpenSpec#2260 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: ESP 1 UKĐang mởcheck:passed streams:add
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:infra area:storage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
THU-MAIC/OpenMAIC#2311 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày