Spell `Selector` without the self-reference its base type holds
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, typescript
- 領域
- backend
調査の方向性
Start by tracing the Selector and Container type declarations and the Node union, then reproduce the reported TS5115 with the consumer example under TypeScript 7.1 nightly. Compare the listed type spellings against the supported TypeScript versions and decide how selector children should be represented. Done means the chosen approach checks for consumers on the nightly without breaking the listed released versions.
索引モデルが issue の本文から書いたものです。
説明
Selector no longer checks on the TypeScript 7.1 nightlies, since the nightly of 2026-09-29.
$ npm i -D typescript@next
$ tsc --noEmit --strict --skipLibCheck app.ts
app.ts(9,20): error TS5115: Instantiations of the following types appear infinitely circular: 'Container', 'Diff'.
The error is reported where Selector is used, not in the declaration, so it depends on what the consumer does with the type rather than on the package alone.
The spelling is the workaround of #232: type Selector = _Selector<Selector> over interface _Selector<S> extends Container<string, Diff<Node, S>>. No released TypeScript is affected — 4.0.3, 4.9.5, 5.0.4, 5.9.3 and 7.0.2 all check it — and the nightlies of 2026-09-28 and earlier do too.
Here is what each spelling costs, measured with tsc --noEmit --strict on a consumer that narrows a selector's children by type and reads them:
spelling of Selector |
4.0.3 | 5.9.3 | 7.0.2 | 7.1 nightly |
|---|---|---|---|---|
_Selector<S> + type Selector = _Selector<Selector>, as shipped |
ok | ok | ok | TS5115 |
interface Selector extends Container<string, Exclude<Node, Selector>> |
TS2310 | TS2310 | TS2310 | ok |
interface Selector extends Container<string, Diff<Node, Selector>> |
TS2310 | TS2310 | TS2310 | ok |
interface Selector extends Container<string, Diff<Node, NodeTypes["selector"]>> |
TS2310 | TS2310 | TS2310 | ok |
type SelectorChild = Diff<Node, Selector>, Selector extends Container<string, SelectorChild> |
TS2310 | TS2310 | TS2310 | ok |
interface Selector<S = Selector> extends Container<string, Diff<Node, S>> |
errors | errors | errors | errors |
interface Selector extends Container<string, Node> |
ok | ok | ok | ok |
A selector that says its children are the nodes that are not selectors has to name the node union in its own base type, and that union holds Selector — which is the cycle, whichever way it is spelled. Adding a default argument to _Selector changes nothing, since the alias still names itself.
So there seem to be three ways out, and I would rather ask than pick:
- drop the exclusion, so a selector's children are
Node[]. The parser never puts a selector inside a selector, butselector.nodeswas the one place in the tree that said so. - declare
nodesonSelectoritself rather than throughContainer, if that keeps the base type free of the node union. - leave it, and let the consumers on the nightly carry a patch until 7.1 ships.
We hit this in stylelint-stylistic, which pins typescript@next; the workaround there is a patchedDependencies entry that would be glad to drop once any of the lands.
- 主要言語
- JavaScript
- スター
- 216
- フォーク
- 81
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
postcss/postcss-selector-parser のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
postcss/postcss-selector-parser#344 · リアクション 6 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
Attribute selector with no valid attribute name throws a raw TypeError, or emits the text "undefined"対応中かも @theRizwan が 72 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
-
[tentative] Add support for `.foo-*` class prefix selectors対応中かも @MoOx が 73 日前に担当しました。 オープン
postcss/postcss-selector-parser#332 · リアクション 1 件 · 担当者 2 名 ·
-
Attribute selector's case-sensitivity identifier `s`対応中かも @abhu85 が 90 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
postcss/postcss-selector-parser#309 · コメント 1 件 ·
postcss/postcss-selector-parser の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
maintenance
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
alphagov/accessible-autocomplete#826 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
olahol/react-tagsinput#229 ·
-
[BUG] npm pkg delete removes the first array item for a nonexistent property対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
jonathanong/no-mistakes#2260 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信