Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Spell `Selector` without the self-reference its base type holds

オープン
#348 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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, but selector.nodes was the one place in the tree that said so.
  • declare nodes on Selector itself rather than through Container, 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

postcss/postcss-selector-parser のほかの issue

postcss/postcss-selector-parser の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。