Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: display correct signature #596

Merged
merged 5 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/apidoc/directMethods.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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