@@ -1790,21 +1790,21 @@ const _NO_SKIP_TYPES = new Uint8Array(32);
17901790// rules, the common case. Every consumer reads these lists read-only, so one
17911791// instance replaces an empty array per rule, and freezing makes a push fail.
17921792const _EMPTY_LIST = /** @type {Rule[]} */ (
1793- /** @type {unknown } */ (Object.freeze([]))
1793+ /** @type {Rule[] | ReadonlyArray<never> } */ (Object.freeze([]))
17941794);
17951795// `consumeABlock`'s and `consumeABlocksContentsInto`'s results, written instead
17961796// of returned — see there. Read them immediately; the next block overwrites them.
17971797/** @type {Declaration[]} */
17981798let _blockDecls = /** @type {Declaration[]} */ (
1799- /** @type {unknown } */ (_EMPTY_LIST)
1799+ /** @type {Declaration[] | Rule[] } */ (_EMPTY_LIST)
18001800);
18011801/** @type {Rule[]} */
18021802let _blockRules = _EMPTY_LIST;
18031803let _blockStart = 0;
18041804let _blockEnd = 0;
18051805/** @type {Declaration[]} */
18061806let _bcDecls = /** @type {Declaration[]} */ (
1807- /** @type {unknown } */ (_EMPTY_LIST)
1807+ /** @type {Declaration[] | Rule[] } */ (_EMPTY_LIST)
18081808);
18091809/** @type {Rule[]} */
18101810let _bcRules = _EMPTY_LIST;
@@ -1888,17 +1888,20 @@ let _declBodies = [];
18881888/** @type {Node[][]} */
18891889let _ruleBodies = [];
18901890
1891- let _locConverter = /** @type {LocConverter} */ (/** @type {unknown} */ (null));
1891+ let _locConverter = /** @type {LocConverter} */ (
1892+ /** @type {LocConverter | null} */ (null)
1893+ );
18921894// The caller's input before §3.3 replaced its NULs, the same length, which
18931895// `A.source` slices so a node reads exactly as written.
18941896let _originalInput = "";
18951897
18961898// Node refs are integers here but typed `Node` across the parser; these are
18971899// identity casts that just satisfy the type system at the boundary.
18981900/** @type {(n: Node) => number} */
1899- const _nodeIndex = (n) => /** @type {number} */ (/** @type {unknown} */ (n));
1901+ const _nodeIndex = (n) =>
1902+ /** @type {number} */ (/** @type {number | Node} */ (n));
19001903/** @type {(i: number) => Node} */
1901- const _nodeRef = (i) => /** @type {Node} */ (/** @type {unknown } */ (i));
1904+ const _nodeRef = (i) => /** @type {Node} */ (/** @type {Node | number } */ (i));
19021905
19031906/** @param {number} need minimum capacity */
19041907const _grow = (need) => {
@@ -2583,7 +2586,7 @@ const normalizeIntoTokenStream = (input, pos, onComment) => {
25832586// Shared frozen empty list for a block body with no declarations / child rules,
25842587// so equal-empty reads return one reference (mirrors `_EMPTY_LIST`).
25852588const _READER_EMPTY = /** @type {Rule[]} */ (
2586- /** @type {unknown } */ (Object.freeze([]))
2589+ /** @type {Rule[] | ReadonlyArray<never> } */ (Object.freeze([]))
25872590);
25882591
25892592/**
@@ -2651,7 +2654,7 @@ const _readRefList = (store, list) => {
26512654// that reader's `_store` snapshot by `_i`. Created once rather than per store,
26522655// so all readers share one hidden map and stay monomorphic across parses.
26532656const NODE_READER_PROTO = /** @type {NodeReader} */ ({
2654- _store: /** @type {NodeStore} */ (/** @type {unknown } */ (null)),
2657+ _store: /** @type {NodeStore} */ (/** @type {NodeStore | null } */ (null)),
26552658 _i: 0,
26562659 get type() {
26572660 return this._store.types[this._i];
@@ -2880,7 +2883,9 @@ const _finishStore = () => {
28802883 _ruleBodies = [];
28812884 _listPool.length = 0;
28822885 _S._input = "";
2883- _locConverter = /** @type {LocConverter} */ (/** @type {unknown} */ (null));
2886+ _locConverter = /** @type {LocConverter} */ (
2887+ /** @type {LocConverter | null} */ (null)
2888+ );
28842889 return store;
28852890};
28862891
@@ -3271,8 +3276,8 @@ const consumeAQualifiedRule = (ts, stopToken, nested = false) => {
32713276 // two non-whitespace tokens the `--foo: {` disambiguation below needs.
32723277 const skip = _skipSelectorPrelude;
32733278 // Non-skip: first two non-whitespace prelude nodes (computed at the `{`).
3274- let first = /** @type {Node} */ (/** @type {unknown } */ (0));
3275- let second = /** @type {Node} */ (/** @type {unknown } */ (0));
3279+ let first = /** @type {Node} */ (/** @type {Node | number } */ (0));
3280+ let second = /** @type {Node} */ (/** @type {Node | number } */ (0));
32763281 // Skip mode: the same two tokens tracked by token type + start, so a dropped
32773282 // leaf selector token needs no materialized node just for the disambiguation.
32783283 // `0` (no token type) = unset.
@@ -4475,7 +4480,9 @@ const TOP_LEVEL_CONSUMERS = {
44754480// recursive call sites monomorphic and allocates no closure per parse.
44764481/** @typedef {import("../util/SourceProcessor").CompiledVisitorBucket<CssPath>} CompiledVisitorBucket */
44774482/** @type {CompiledVisitorMap} */
4478- let _visitors = /** @type {CompiledVisitorMap} */ (/** @type {unknown} */ ([]));
4483+ let _visitors = /** @type {CompiledVisitorMap} */ (
4484+ /** @type {CompiledVisitorMap | never[]} */ ([])
4485+ );
44794486let _recurseBlocks = true;
44804487// Printing needs a faithful serialization, so it keeps dropped input as `NodeType.Raw`
44814488// nodes; a walk-only parse leaves this false and allocates none.
@@ -5090,10 +5097,10 @@ const UNKEYED = "";
50905097/** @type {BlockSpans[]} */
50915098const _blockSpans = [];
50925099const _NO_RULE_SPANS = /** @type {RuleSpan[]} */ (
5093- /** @type {unknown } */ (Object.freeze([]))
5100+ /** @type {RuleSpan[] | ReadonlyArray<never> } */ (Object.freeze([]))
50945101);
50955102const _NO_BLOCK_SPANS = /** @type {BlockSpans[]} */ (
5096- /** @type {unknown } */ (Object.freeze([]))
5103+ /** @type {BlockSpans[] | ReadonlyArray<never> } */ (Object.freeze([]))
50975104);
50985105/**
50995106 * @typedef {{ piece: number, text: string, spans: RuleSpan[], empties: number }} TakenPiece
@@ -8221,7 +8228,9 @@ const grammar = (input, visitors, writer, options) => {
82218228 _anonymousLayers = 0;
82228229 _S._input = "";
82238230 _originalInput = "";
8224- _locConverter = /** @type {LocConverter} */ (/** @type {unknown} */ (null));
8231+ _locConverter = /** @type {LocConverter} */ (
8232+ /** @type {LocConverter | null} */ (null)
8233+ );
82258234 _declBodies.length = 0;
82268235 _ruleBodies.length = 0;
82278236 _flatTop = 0;
@@ -8230,7 +8239,9 @@ const grammar = (input, visitors, writer, options) => {
82308239 _flatGrowHint = _flatPeak;
82318240 _flat = EMPTY_I32;
82328241 }
8233- _visitors = /** @type {CompiledVisitorMap} */ (/** @type {unknown} */ ([]));
8242+ _visitors = /** @type {CompiledVisitorMap} */ (
8243+ /** @type {CompiledVisitorMap | never[]} */ ([])
8244+ );
82348245 _commentBucket = undefined;
82358246 if (_capacity > _SHRINK_CAPACITY) {
82368247 // +1: node ids are 1-based and grow fires at `id >= capacity`.
@@ -11012,7 +11023,7 @@ const _resolveColor = (text) => {
1101211023 }
1101311024 // Every call that answers records them, so a non-null answer is one.
1101411025 const raw = /** @type {number[]} */ (
11015- /** @type {unknown } */ (_fallbackChannels)
11026+ /** @type {number[] | null } */ (_fallbackChannels)
1101611027 );
1101711028 return {
1101811029 linear: raw.map((channel) => _gammaDecode(channel / 255)),
@@ -19222,7 +19233,7 @@ const _S = {
1922219233 // The walk's current position (`A.node` / `A.parent` read these; module-level
1922319234 // so the accessor methods' defaults avoid self-referential `this` typing).
1922419235 /** @type {Node} */
19225- _currentNode: /** @type {Node} */ (/** @type {unknown } */ (0)),
19236+ _currentNode: /** @type {Node} */ (/** @type {Node | number } */ (0)),
1922619237 // The declaration `_inKeywordOnlyValue` last answered for, and its answer: one
1922719238 // value's identifiers all ask it, and the read is a pointer compare after the
1922819239 // first. Cleared with the rest of the parse state, so no node outlives it.
0 commit comments