Spell `Selector` without the self-reference its base type holds
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, typescript
- Domínio
- backend
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- JavaScript
- Estrelas
- 216
- Forks
- 81
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de postcss/postcss-selector-parser
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
postcss/postcss-selector-parser#344 · 6 reações ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
-
Attribute selector with no valid attribute name throws a raw TypeError, or emits the text "undefined"Talvez já em andamento @theRizwan assumiu há 72 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 74/100
-
[tentative] Add support for `.foo-*` class prefix selectorsTalvez já em andamento @MoOx assumiu há 73 dias. Aberta
postcss/postcss-selector-parser#332 · 1 reação · 2 responsáveis ·
-
Attribute selector's case-sensitivity identifier `s`Talvez já em andamento @abhu85 assumiu há 90 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
postcss/postcss-selector-parser#309 · 1 comentário ·
Todas as issues de postcss/postcss-selector-parser
Issues semelhantes
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 2 dias
-
feedback simulation workshop
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
githubnext/gh-aw-workshop#4755 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
videojs/video.js#9537 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
fix
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
idean3885/claude-ops-agent#728 ·
Mantenedores costumam responder em até 1 dia