simplify - we can enforce readonly at a type level

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

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

Loading…
Cancel
Save