Message from JavaScript discussions

September 2020

— Krust

— 

const e = document.createElement('span');
e.appendChild(document.createElement('div'));
const we = e as WithADiv;

into
const e = document.createElement('span');
e.appendChild(document.createElement('div'));
if (!(e.children.filter(n => n instanceof HTMLDivElement).length === 1))
throw new TSError('or something');
const we = e;

— That'd be cool

— Wrapping block-level element into inline-level element not cool, but that's only a top of an iceberg i suppose

Message permanent page

— Wat

— Actually in the newer versions of TS you can do these things

— Development versions

— This doesn't exist though

— Runtime type checking is a no-no

— Libraries like zod solves that for you

— Zog🤧

— Zod*