Working with Modules
Default Export Function
A default export is the single main value a module exposes.
default export
`export default` marks one declaration as the primary export of the module.
Default Export Function
default_export.ts
Replay: real traced execution (multi-file project)
export default function titleCase(text: string): string {
return text
.split(" ")
.map((word) => word[0].toUpperCase() + word.slice(1))
.join(" ");
}
const rawTitle: string = "trace replay";
const title: string = titleCase(rawTitle);
console.log(title);
export default function titleCase(text: string): string {
return text
.split(" ")
.map((word) => word[0].toUpperCase() + word.slice(1))
.join(" ");
}
const rawTitle: string = "module boundary";
const title: string = titleCase(rawTitle);
console.log(title);
rawTitle ← trace replay
5 .join(" ");6}78const rawTitle→ trace replay: string = "trace replay"; //@rawTitle="module boundary"9const title: string = titleCase(rawTitletrace replay);export default function titleCase(text: string): string
1export default function titleCase(texttrace replay: string): string {2 return texttrace replay3 .split(" ")4 .map((word) => word[0].toUpperCase() + word.slice(1))5 .join(" ");6}title ← Trace Replay
8const rawTitle: string = "trace replay"; //@rawTitle="module boundary"9const title→ Trace Replay: string = titleCase(rawTitletrace replay);1011console.log(titleTrace Replay);outputTrace Replay
rawTitle ← module boundary
5 .join(" ");6}78const rawTitle→ module boundary: string = "module boundary";9const title: string = titleCase(rawTitlemodule boundary);export default function titleCase(text: string): string
1export default function titleCase(textmodule boundary: string): string {2 return textmodule boundary3 .split(" ")4 .map((word) => word[0].toUpperCase() + word.slice(1))5 .join(" ");6}title ← Module Boundary
8const rawTitle: string = "module boundary";9const title→ Module Boundary: string = titleCase(rawTitlemodule boundary);1011console.log(titleModule Boundary);outputModule Boundary