Featured image of post Ts to Jsdoc

Ts to Jsdoc

Ts to Jsdoc

Generics

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

1
type List<T> = []T
1
2
3
4
/**
 * @template T
 * @typedef {[]T} List
 */

reducer

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

is equivalent to

1
2
3
4
const reducer = (
	/** @type {number[]} */ state,
	/** @type {number} */ action
) => [...state, action]
Licensed under CC BY-NC-SA 4.0
好想養貓阿~~
使用 Hugo 建立
主題 StackJimmy 設計