Document overloaded function in JSDoc

前端 未结 2 910
礼貌的吻别
礼貌的吻别 2021-01-21 00:40

I have an overloaded toggle function and want to document the behaviors w/ JSDoc.

If the value is defined the window state is set to the boolean value o

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-21 00:55

    Since the previous answer didn't work for me. Try:

    /** @type {((param: string) => boolean) & ((param: string, overloadedParam: string) => string))} */
    const func = (param, overloadedParam) => { … }
    

    Please give credit for this answer to ExE-Boss on GitHub, found here: https://github.com/microsoft/TypeScript/issues/25590#issuecomment-480022039

    (this works in standard JS, as well as TS)

提交回复
热议问题