長條貓窩

Back

(Legacy)

Ts to Jsdoc#

Generics#

https://medium.com/@antonkrinitsyn/jsdoc-generic-types-typescript-db213cf48640

type List<T> = []T
ts
/**
 * @template T
 * @typedef {[]T} List
 */
js

reducer#

const reducer = (state: number[], action: number) => [...state, action]
ts

is equivalent to

const reducer = (
	/** @type {number[]} */ state,
	/** @type {number} */ action
) => [...state, action]
js
Ts to Jsdoc
https://blog.simbafs.cc/blog/ts-to-jsdoc/
Author Simba Fs
Published at September 2, 2023