Skip to content

Commit

Permalink
docs: display correct signature (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Mar 7, 2022
1 parent 3c82057 commit c115056
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scripts/apidoc/directMethods.ts
Expand Up @@ -41,8 +41,9 @@ export function processDirectMethod(
methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
console.log(`Processing Direct: ${upperMethodName}`);

const signature = (direct.type as TypeDoc.ReflectionType).declaration
.signatures[0];
const signatures = (direct.type as TypeDoc.ReflectionType).declaration
.signatures;
const signature = signatures[signatures.length - 1];

writeApiDocsDirectPage(methodName);
writeApiDocsData(methodName, [
Expand Down
3 changes: 2 additions & 1 deletion scripts/apidoc/moduleMethods.ts
Expand Up @@ -50,7 +50,8 @@ function processModuleMethod(module: TypeDoc.DeclarationReflection): PageIndex {
)) {
const methodName = method.name;
console.debug(`- ${methodName}`);
const signature = method.signatures[0];
const signatures = method.signatures;
const signature = signatures[signatures.length - 1];

methods.push(analyzeSignature(signature, lowerModuleName, methodName));
}
Expand Down
20 changes: 20 additions & 0 deletions src/random.ts
Expand Up @@ -179,6 +179,26 @@ export class Random {
object: T,
field?: unknown
): T[K];
/**
* Returns a random key or value from given object.
*
* @template T The type of `Record` to pick from.
* @template K The keys of `T`.
* @param object The object to get the keys or values from.
* @param field If this is set to `'key'`, this method will a return a random key of the given instance.
* If this is set to `'value'`, this method will a return a random value of the given instance.
* Defaults to `'value'`.
*
* @example
* const object = { keyA: 'valueA', keyB: 42 };
* faker.random.objectElement(object) // 42
* faker.random.objectElement(object, 'key') // 'keyB'
* faker.random.objectElement(object, 'value') // 'valueA'
*/
objectElement<T extends Record<string, unknown>, K extends keyof T>(
object: T,
field?: 'key' | 'value'
): K | T[K];
objectElement<T extends Record<string, unknown>, K extends keyof T>(
object = { foo: 'bar', too: 'car' } as unknown as T,
field = 'value'
Expand Down

0 comments on commit c115056

Please sign in to comment.