Skip to content

Instantly share code, notes, and snippets.

@robfe
Created March 21, 2018 20:09
Show Gist options
  • Save robfe/0e4cf56b2c87ccd8f663e7b960205672 to your computer and use it in GitHub Desktop.
Save robfe/0e4cf56b2c87ccd8f663e7b960205672 to your computer and use it in GitHub Desktop.
let rows: string[] = [];
for (let count = 1; count <= 10; count++) {
let numbers = Array.from(new Array(count)).map((x, i) => i + 1);
let genericDef = numbers.map(x => `T${x} extends string`).join(', ');
let parameterDef = numbers.map(x => `a${x}: T${x}`).join(', ');
let recordDef = numbers.map(x => `T${x}`).join('|');
rows.push(`<${genericDef}>(strings: TemplateStringsArray, ${parameterDef}): HasRouteTemplate & ((r: Record<${recordDef}, string>) => string);`);
}
console.log('\n\n' + rows.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment