Spell `Selector` without the self-reference its base type holds
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 216
- Fork
- 81
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 postcss/postcss-selector-parser
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
postcss/postcss-selector-parser#344 · 6 reaction ·
-
Using @csstools/css-tokenizerĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Attribute selector with no valid attribute name throws a raw TypeError, or emits the text "undefined"Có thể đã có người làm @theRizwan đã nhận 72 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
-
[tentative] Add support for `.foo-*` class prefix selectorsCó thể đã có người làm @MoOx đã nhận 73 ngày trước. Đang mở
postcss/postcss-selector-parser#332 · 1 reaction · 2 người được giao ·
-
Attribute selector's case-sensitivity identifier `s`Có thể đã có người làm @abhu85 đã nhận 90 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
postcss/postcss-selector-parser#309 · 1 bình luận ·
Tất cả issue của postcss/postcss-selector-parser
Issue tương tự
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
maintenance
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
alphagov/accessible-autocomplete#826 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
olahol/react-tagsinput#229 ·
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jonathanong/no-mistakes#2260 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày