bug: v5 dist/types/components.d.ts imports @stencil/core/runtime instead of ./stencil-public-runtime
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- build-system
調査の方向性
まず packages/core/src/compiler/types/stencil-types.ts の updateStencilTypesImports() を読み、generateAppTypes() が dist/types/components.d.ts にどのように適用するかを追ってください。Issue によると、書き換えは依然として Stencil 4 の import に一致しますが、Stencil 5 は @stencil/core/runtime を出力します。リンクされた types-import ワークスペースで再現してください。生成された宣言が ./stencil-public-runtime を import し、再現時に意図的なタイプミス labell だけが報告されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 13.2k
- フォーク
- 870
- 平均マージ
- 2日 54分
- マージ済み PR(30日)
- 50
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stenciljs/core のほかの issue
-
Stencil FOUC styles should use @layer to avoid cascade conflicts with React 19対応中かも @johnjenkins が 241 日前に担当しました。 オープンStencil v5
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug: v5 streamed SSR host is released too early when a script inserts a node while it is parsedオープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
feat: write reflected attributes when the prop changes, not on the next render対応中かも @johnjenkins が 241 日前に担当しました。 オープンStencil v5
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
feat: css source map support対応中かも @Elements2720 が 37 日前に担当しました。 オープンFeature: Want this? Upvote it!
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
stenciljs/core#6964 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
posit-dev/positron-sas-extension#196 ·
メンテナーはふだん 1 日以内に返信
-
bug composer
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
inmanta/web-console#8037 ·
メンテナーはふだん 1 日以内に返信
-
check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信