Skip to content

Commit

Permalink
fix: Improve type params table readability
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jun 23, 2021
1 parent 1b3395f commit 52038e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Expand Up @@ -32,12 +32,15 @@ function table(parameters: any) {
row.push(`\`${parameter.name}\``);

if (showTypeCol) {
const typeCol: string[] = [`\`${parameter.name}\``];
const typeCol: string[] = [];
if (!parameter.type && !parameter.default) {
typeCol.push(`\`${parameter.name}\``);
}
if (parameter.type) {
typeCol.push(`: ${type.call(parameter.type, 'object')}`);
typeCol.push(`extends ${type.call(parameter.type, 'object')}`);
}
if (parameter.default) {
typeCol.push(` = ${type.call(parameter.default)}`);
typeCol.push(type.call(parameter.default));
}
row.push(typeCol.join(''));
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ exports[`Declarations: should compile any function type 1`] = `
| Name | Type |
| :------ | :------ |
| \`A\` | \`A\` = \`any\` |
| \`A\` | \`any\` |
#### Type declaration
Expand Down
Expand Up @@ -46,9 +46,9 @@ exports[`Generics: should compile function with complex type params' 1`] = `
| Name | Type | Description |
| :------ | :------ | :------ |
| \`A\` | \`A\`: [\`ClassWithTypeParams\`](classwithtypeparams.md)<\`string\`, \`number\`, \`A\`\\\\> | Comment for type \`A\` |
| \`B\` | \`B\` = \`string\` \\\\| \`boolean\` | Comment for type \`B\` |
| \`C\` | \`C\` = \`string\` | - |
| \`A\` | extends [\`ClassWithTypeParams\`](classwithtypeparams.md)<\`string\`, \`number\`, \`A\`\\\\> | Comment for type \`A\` |
| \`B\` | \`string\` \\\\| \`boolean\` | Comment for type \`B\` |
| \`C\` | \`string\` | - |
##### Returns
Expand Down

0 comments on commit 52038e2

Please sign in to comment.