testOptionalChildrenAreLabelledBySlot
Optional children are labelled by slot.
import { hashes } from "#codebase/tcmts/core/test/hash"; import assert from "node:assert/strict"; export const testOptionalChildrenAreLabelledBySlot = () => { // the same child in another optional slot: without labels, both would be a for with `i` and a body const f = (src: string) => hashes(`const f = (i: number) => { ${src} }`).f; assert.notEqual(f(`for (i; ;) { break; }`), f(`for (; i;) { break; }`)); assert.notEqual(f(`for (; i;) { break; }`), f(`for (; ; i) { break; }`)); // an optional child present or not stays apart too assert.notEqual(hashes(`class A { m?(): void {} }`).A, hashes(`class A { m(): void {} }`).A); }