simplify - we can enforce readonly at a type level

pull/16748/head
Rich Harris 5 days ago
parent 673e9151ca
commit 1abf3d0414

@ -362,43 +362,26 @@ export class Payload {
} }
export class TreeState { export class TreeState {
/** @type {() => string} */ /** @readonly @type {'sync' | 'async'} */
#uid; mode;
/** @type {Set<{ hash: string; code: string }>} */
#css;
/** @type {TreeHeadState} */ /** @readonly @type {() => string} */
#head; uid;
/** @type {'sync' | 'async'} */ /** @readonly @type {TreeHeadState} */
#mode; head;
get css() { /** @readonly @type {Set<{ hash: string; code: string }>} */
return this.#css; css = new Set();
}
get uid() {
return this.#uid;
}
get head() {
return this.#head;
}
get mode() {
return this.#mode;
}
/** /**
* @param {'sync' | 'async'} mode * @param {'sync' | 'async'} mode
* @param {string} [id_prefix] * @param {string} [id_prefix]
*/ */
constructor(mode, id_prefix = '') { constructor(mode, id_prefix = '') {
this.#uid = props_id_generator(id_prefix); this.mode = mode;
this.#css = new Set(); this.uid = props_id_generator(id_prefix);
this.#head = new TreeHeadState(this.#uid); this.head = new TreeHeadState(this.uid);
this.#mode = mode;
} }
} }

Loading…
Cancel
Save