Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptfunction overloadsSingle-choice MCQ

Why does `a.href` compile here, where `createElement` is overloaded?

function createElement(tag: "a"): HTMLAnchorElement; function createElement(tag: "div"): HTMLDivElement; function createElement(tag: string): HTMLElement { return document.createElement(tag); } const a = createElement("a"); const href = a.href;