How to document a string type in jsdoc with limited possible values

前端 未结 5 385
春和景丽
春和景丽 2020-12-02 15:08

I am having a function that accepts one string parameter. This parameter can have only one of a few defined possible values. What is the best way to document the same? Shoul

5条回答
  •  天命终不由人
    2020-12-02 15:28

    What about:

    /**
     * @typedef {"keyvalue" | "bar" | "timeseries" | "pie" | "table"} MetricFormat
     */
    
    /**
     * @param format {MetricFormat}
     */
    export function fetchMetric(format) {
        return fetch(`/matric}`, format);
    }
    

提交回复
热议问题