DavidWells/types-with-jsdocs

Using JSDoc for Typescript Types

JavaScript

252

40 commits

updated Apr 16, 2024

See the code

README

Using Typescript Types with JSDoc

Experimentation repo for various ways to type react apps.

See ./src folder for examples

Globally enable TS checking

To enable TS to run everywhere use the js/ts.implicitProjectConfig.checkJS setting in your VScode workspace or user settings.

"js/ts.implicitProjectConfig.checkJs": true

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

Examples

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

example
jsdoc
types
typescript
typescript-library

DavidWells/types-with-jsdocs

Using JSDoc for Typescript Types

JavaScript

252

40 commits

updated Apr 16, 2024

See the code

README

Using Typescript Types with JSDoc

Experimentation repo for various ways to type react apps.

See ./src folder for examples

Globally enable TS checking

To enable TS to run everywhere use the js/ts.implicitProjectConfig.checkJS setting in your VScode workspace or user settings.

"js/ts.implicitProjectConfig.checkJs": true

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

Examples

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

example
jsdoc
types
typescript
typescript-library

Significant stargazers

Titus

3,574 followers · starred Aug 2023

Andrea Giammarchi

2,317 followers · starred Apr 2022

Fil Maj

276 followers · starred Jul 2023

Thorsten Lünborg

2,582 followers · starred Aug 2023