This serves as an instructional starting point for the use of typescript type checking within a regular javascript nodejs project. No compile step is needed, because the project uses JSDoc comments.
- Typescript type checking as you code (thanks to language servers like those in VSCode)
- Modules just work
- No source code maps
- Debugging just works (e.g. breakpoints)
- No compile step
- No watchers
- Everything is instantaneously ready (faster than vite!)
- Compatible with client-side browser javascript engines (see importmaps)
- To be useful, this depends heavily on a language server in your code editor to show type errors as you go.
- There is some minimal setup required (see below). Using this template avoids the setup.
The necessary ingredients within this project are as follows:
tsconfig.json
: theallowJs
,checkJs
, andstrict
options set to true.package.json
: thetype
set tomodule
allows nodejs to use ES modules (import
/export
instead ofrequire
).- JSDoc comments with types. See code for examples.