bug: v5 dist/types/components.d.ts imports @stencil/core/runtime instead of ./stencil-public-runtime
Maintainer thường phản hồi trong vòng 1 ngày
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
- 76/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
- build-system
Hướng nghiên cứu
Bắt đầu bằng cách đọc updateStencilTypesImports() trong packages/core/src/compiler/types/stencil-types.ts và theo dõi cách generateAppTypes() áp dụng hàm này cho dist/types/components.d.ts. Issue cho biết thao tác viết lại vẫn khớp với import của Stencil 4, trong khi Stencil 5 xuất ra @stencil/core/runtime; hãy tái hiện bằng workspace types-import được liên kết. Hoàn tất khi khai báo được tạo import ./stencil-public-runtime và kết quả tái hiện chỉ báo lỗi chính tả có chủ ý labell.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Stencil Version
5.0.0-rc.12
Current Behavior
The generated dist/types/components.d.ts imports its base types from @stencil/core:
import { HTMLStencilElement, JSXBase } from "@stencil/core/runtime";
The published types therefore only work in an application that has @stencil/core installed. A library that lists @stencil/core under devDependencies ships types that don't resolve:
library/components.d.ts:6 TS2307: Cannot find module '@stencil/core/runtime' or its corresponding type declarations.
app.ts:5 TS2339: Property 'focus' does not exist on type 'HTMLReproTypesElement'.
The second error is the one an application sees even with skipLibCheck: HTMLReproTypesElement extends Components.ReproTypes, HTMLStencilElement, and with HTMLStencilElement unresolved the element type loses everything it inherits from HTMLElement.
Expected Behavior
dist/types/components.d.ts imports from the stencil-public-runtime.d.ts that Stencil copies into dist/types, so the types are self-contained:
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
This is what 4.45.1 generates, and what Stencil 5 still does for the declaration file of a component (import { type ComponentInterface } from '../stencil-public-runtime' in the reproduction).
System Info
System: node 22.21.0
Platform: darwin (27.0.0)
CPU Model: Apple M2 Pro (12 cpus)
Stencil: 5.0.0-rc.12 🔈
TypeScript: 6.0.3
Rolldown: 1.3.3
Terser: 5.51.4
Steps to Reproduce
- Clone https://github.com/henrijoss/stencil-v5-repros and run
npm install npm install @stencil/[email protected](the repository is pinned to rc.10, which behaves the same)npm run repro --workspace=types-import
The script builds a component with a loader-bundle output target, prints the imports of Stencil in dist/types, copies the types to a folder where @stencil/core can't be resolved, and type-checks a file that uses the element. Output:
Imports of Stencil in dist/types:
components/repro-types.d.ts: import { type ComponentInterface } from '../stencil-public-runtime';
components.d.ts: import { HTMLStencilElement, JSXBase } from "@stencil/core/runtime";
tsc with skipLibCheck: false
lib.dom.d.ts:13098 TS2344: Type 'HTMLElementTagNameMap[K]' does not satisfy the constraint 'Element'. …
lib.dom.d.ts:13729 TS2344: Type 'HTMLElementTagNameMap[K]' does not satisfy the constraint 'Element'. …
lib.dom.d.ts:27097 TS2344: Type 'HTMLElementTagNameMap[K]' does not satisfy the constraint 'Node'. …
app.ts:5 TS2339: Property 'focus' does not exist on type 'HTMLReproTypesElement'.
app.ts:7 TS2551: Property 'labell' does not exist on type 'HTMLReproTypesElement'. Did you mean 'label'?
library/components.d.ts:6 TS2307: Cannot find module '@stencil/core/runtime' or its corresponding type declarations.
tsc with skipLibCheck: true
app.ts:5 TS2339: Property 'focus' does not exist on type 'HTMLReproTypesElement'.
app.ts:7 TS2551: Property 'labell' does not exist on type 'HTMLReproTypesElement'. Did you mean 'label'?
labell is a deliberate typo and the only error with 4.45.1.
Code Reproduction URL
https://github.com/henrijoss/stencil-v5-repros/tree/main/types-import
Additional Information
generateAppTypes() still passes the file through updateStencilTypesImports() when it writes to dist/types, but that function still looks for the import path of Stencil 4 (packages/core/src/compiler/types/stencil-types.ts):
dtsContent = dtsContent.replace(/(from\s*(:?'|"))@stencil\/core\/internal('|")/g, `$1${coreDtsPath}$2`);
dtsContent = dtsContent.replace(/(from\s*(:?'|"))@stencil\/core('|")/g, `$1${coreDtsPath}$2`);
@stencil/core/internal became @stencil/core/runtime in Stencil 5, and generateComponentTypesFile() writes the new path, so the first replacement no longer matches anything. Changing it to @stencil\/core\/runtime fixes the reproduction: components.d.ts imports ./stencil-public-runtime again and only the typo is reported.
A project created with the v5 wizard lists @stencil/core under dependencies, which hides this. A library that keeps it under devDependencies, as https://github.com/stenciljs/component-starter does, is affected.
dist/standalone/<tag>.d.ts has the same import (import type { HTMLStencilElement } from "@stencil/core/runtime"). It doesn't go through dist/types, and 4.45.1 had no such import there, so I can't tell whether it is intended.
I found no existing issue for this.
- Ngôn ngữ chính
- TypeScript
- Star
- 13.2k
- Fork
- 870
- Merge trung bình
- 2 ngày 54 phút
- Pull request đã merge (30 ngày)
- 50
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 stenciljs/core
-
Stencil FOUC styles should use @layer to avoid cascade conflicts with React 19Có thể đã có người làm @johnjenkins đã nhận 241 ngày trước. Đang mởStencil v5
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: v5 streamed SSR host is released too early when a script inserts a node while it is parsedĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feat: write reflected attributes when the prop changes, not on the next renderCó thể đã có người làm @johnjenkins đã nhận 241 ngày trước. Đang mởStencil v5
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feat: css source map supportCó thể đã có người làm @Elements2720 đã nhận 37 ngày trước. Đang mởFeature: Want this? Upvote it!
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
stenciljs/core#6964 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stenciljs/core
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
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 74/100
posit-dev/positron-sas-extension#196 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug composer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
inmanta/web-console#8037 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: AlFajer Palestine FHDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
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 84/100
Maintainer thường phản hồi trong vòng 1 ngày