Jer*_*me 7 generics lint jsdoc typescript
使用 JSDoc 实现通用打字稿功能的最佳方法是什么?下面是我尝试过的方法,但我想有一个最好的方法,因为有一个信息说JSDoc types may be moved to TypeScript types.ts(80004)
我点击了“快速修复”,但这搞乱了功能。
/**
* @description execute in parallel promises by chunks
* @type <ReturnType> : the type of data to be returned
* @param arrayPromises : the array of promises to execute
* @param chunks : the value of chunks
* @returns : an array of returnType
*/
const runPromisesInParallelbyChunks = async <ReturnType>(
arrayPromises: Array<() => Promise<ReturnType>>,
chunks: number
): Promise<ReturnType[]> => {
const result: ReturnType[] = [];
let resu: ReturnType[] = [];
let cnt: number = 0;
const chain = async (
shrinkArray: Array<() => Promise<ReturnType>>
): Promise<ReturnType> => {
if (!shrinkArray.length) {
return new Promise<ReturnType>(resolve => resolve());
}
// console.log(shrinkArray.length);
const i: number = cnt++;
const res: ReturnType = await shrinkArray.shift()!();
await delayExecution(100);
// SAVE RESULT OF THE EXECUTION OF THE FUNCTION
result[i] = res;
return chain(shrinkArray);
};
const arrChains: Array<Promise<ReturnType>> = [];
while (chunks-- > 0 && arrayPromises.length > 0) {
arrChains.push(chain(arrayPromises));
}
// RESULT IS AN ARRAY OF THE RESULT OF EACH PROMISE
resu = await Promise.all(arrChains).then(() => result);
return resu;
};
Run Code Online (Sandbox Code Playgroud)
小智 1
听起来 @type 不需要在那里。我的 @params 中有类型,一旦我把它们拿出来,我就不再得到这个了。
@param {string} containerName - Name of the container.
public async exampleFunc(containerName: string)
Run Code Online (Sandbox Code Playgroud)
到
@param containerName - Name of the container.
public async exampleFunc(containerName: string)
Run Code Online (Sandbox Code Playgroud)
https://dev.to/kamranayub/why-you-don-t-need-types-in-jsdoc-when-documenting-typescript-1pb0
| 归档时间: |
|
| 查看次数: |
3380 次 |
| 最近记录: |