Types with JSDoc is a set of examples showing how JavaScript projects can get strong editor support and type checking without converting every file to TypeScript.
It matches the way this site is built: JavaScript with checkJs, JSDoc annotations, and generated types where they help.
Typed JavaScript is a practical middle ground for existing codebases. It improves tooling and correctness while keeping the authoring model lightweight.
Full documentation, synced from the package README:
Experimentation repo for various ways to type react apps.
See ./src folder for examples
To enable TS to run everywhere use the js/ts.implicitProjectConfig.checkJS setting in your VScode workspace or user settings.
"js/ts.implicitProjectConfig.checkJs": trueThe //@ts-ignore tells TypeScript to ignore the TypeScript errors in the line following the comment.
function mapValues(object, mapFunction) {
// @ts-ignore
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFunction(value)]))
}This //@ts-expect-error will ignore any typechecking failures in the next line, but will fail the typecheck if there are no errors
function mapValues(object, mapFunction) {
//@ts-expect-error
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFunction(value)]))
}// @ts-ignore-start
// @ts-ignore-endNuclear option to disable in file
// @ts-nocheckquerySelector and querySelectorAll@microsoft/api-extractor @microsoft/api-documenter