recursion - How can I infer a recursive TypeScript Type? -
i building typescript collection class application have struggled find solution in order infer recursive calls. arrays.ts export interface arrayable<t> { toarray(): array<t>; } export function isarrayable<t>(object: any): object arrayable<t> { return typeof object === "object" && 'toarray' in object; } collection.ts import { arrayable, isarrayable } "./arrays"; export class collection<t> implements arrayable<t> { private elements: array<t>; constructor(elements?: array<t> | arrayable<t>) { if (typeof elements === "undefined") return; this.elements = this.getelementsarray(elements); } chunk(size: number): collection<collection<t>> { let chunked = []; (let = 0, len = this.elements.length; < len; += size) chunked.push(new collection(this.elements.slice(i, + size))); return new coll...