Skip to content

DoK6n/types-with-jsdocs

 
 

Repository files navigation

Using Typescript Types with JSDoc

Experimentation repo for various ways to type react apps.

See ./src folder for examples

Typescript ignore errors

Pro-tip: CLI tool to automatically add ignore comments

The //@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)]))
}

Ignoring multiple lines

// @ts-ignore-start
// @ts-ignore-end

Nuclear option to disable in file

// @ts-nocheck

Resources & Articles

Tools

Doc parsers

Formatters

Conversion tools

Extra imported types

Doc Generators

Runtime type checkers

VScode extensions

Msc

Examples

Using test code for docs

About

Using JSDoc for Typescript Types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.0%
  • TypeScript 18.3%
  • Other 0.7%