Make TypeDoc Generate a 404 Page

Motivation TypeDoc is a document generator that, among other things, converts comments in TypeScript source code into rendered HTML documentation. The generated HTML documentation can be hosted on static website hosting services, such as GitHub Pages, GitLab Pages, Netlify, and CloudFlare Pages. All of them by default use a 404.html file as the content of the 404 page of the site. However, TypeDoc does not generate a 404.html by default. How can we make TypeDoc generate such a 404.html file? ...

April 6, 2024 · (updated May 13, 2024) · 3 min · 464 words

Typing Wrapper Functions in Typescript

Motivation Very often in TypeScript, we would like to wrap an existing function into a wrapper function, with some additional preprocessing or postprocessing. For example, function existingFunc(arg1: number, arg2: string): number { return arg1 + arg2.length; } function wrapperFunc(arg1: number, arg2: string): number { // Preprocess arg1 and arg2... return existingFunc(arg1, arg2); } In this case, the wrapper function often shares the same parameter types and return type. If the existing function is already typed, we can reuse those typing information. This would reduce redundancy and is also able to reflect any changes that would happen in the typing of the existing function in the future. ...

April 3, 2024 · (updated May 13, 2024) · 3 min · 539 words

Test the Presence of a Material UI Icon in Jest/Vitest

Testing the presence of a Material UI Icon in Jest/Vitest can be done by using the Testing Library. First, in the production code, assign a titleAccess attribute to the icon. For example, if the icon of interest is AddIcon, the code would look like: <AddIcon titleAccess="My Add Icon" /> This attribute would also surface to the user interface. ...

April 2, 2024 · (updated May 13, 2024) · 1 min · 197 words