Skip to content

Commit

Permalink
JSDocs are missing for overloaded functions #10012
Browse files Browse the repository at this point in the history
  • Loading branch information
edloidas committed Feb 1, 2023
1 parent 779da77 commit 098ecee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions modules/lib/lib-auth/src/main/resources/lib/xp/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ interface GetUserHandler {
getUser(): User | null;
}

export function getUser(params?: { includeProfile?: false }): User | null;
export function getUser<Profile extends Record<string, unknown> = Record<string, unknown>>(params: { includeProfile: true }): UserWithProfile<Profile> | null;
/**
* Returns the logged-in user. If not logged-in, this will return *undefined*.
*
Expand All @@ -150,8 +152,6 @@ interface GetUserHandler {
*
* @returns {User} Information for logged-in user.
*/
export function getUser(params?: { includeProfile?: false }): User | null;
export function getUser<Profile extends Record<string, unknown> = Record<string, unknown>>(params: { includeProfile: true }): UserWithProfile<Profile> | null;
export function getUser(params?: GetUserParams): User | null {
const {
includeProfile = false,
Expand Down Expand Up @@ -245,6 +245,9 @@ interface GetPrincipalHandler {
getPrincipal(): Principal | null;
}

export function getPrincipal(userKey: UserKey): User | null;
export function getPrincipal(groupKey: GroupKey): Group | null;
export function getPrincipal(roleKey: RoleKey): Role | null;
/**
* Returns the principal with the specified key.
*
Expand All @@ -253,9 +256,6 @@ interface GetPrincipalHandler {
* @param {string} principalKey Principal key to look for.
* @returns {User | Group | Role} the principal specified, or null if it doesn't exist.
*/
export function getPrincipal(userKey: UserKey): User | null;
export function getPrincipal(groupKey: GroupKey): Group | null;
export function getPrincipal(roleKey: RoleKey): Role | null;
export function getPrincipal(principalKey: PrincipalKey): Principal | null {
checkRequiredValue(principalKey, 'principalKey');

Expand Down Expand Up @@ -732,6 +732,8 @@ interface FindUsersHandler {
execute(): FindPrincipalsResult<User | UserWithProfile>;
}

export function findUsers(params: FindUsersParams & {includeProfile?: false}): FindPrincipalsResult<User>;
export function findUsers<Profile extends Record<string, unknown> = Record<string, unknown>>(params: FindUsersParams & {includeProfile: true}): FindPrincipalsResult<UserWithProfile<Profile>>;
/**
* Search for users matching the specified query.
*
Expand All @@ -746,8 +748,6 @@ interface FindUsersHandler {
*
* @returns {FindPrincipalsResult} Result of query.
*/
export function findUsers(params: FindUsersParams & {includeProfile?: false}): FindPrincipalsResult<User>;
export function findUsers<Profile extends Record<string, unknown> = Record<string, unknown>>(params: FindUsersParams & {includeProfile: true}): FindPrincipalsResult<UserWithProfile<Profile>>;
export function findUsers(params: FindUsersParams): FindPrincipalsResult<User | UserWithProfile> {
const {
start = 0,
Expand Down
8 changes: 4 additions & 4 deletions modules/lib/lib-node/src/main/resources/lib/xp/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,20 +628,20 @@ class RepoConnectionImpl
return __.toNativeObject(this.nodeHandler.modify(__.toScriptValue(params.editor), params.key));
}

get<NodeData = Record<string, unknown>>(keys: string | GetNodeParams): Node<NodeData> | null;
get<NodeData = Record<string, unknown>>(keys: (string | GetNodeParams)[]): Node<NodeData>[] | null;
get<NodeData = Record<string, unknown>>(...keys: (string | GetNodeParams | (string | GetNodeParams)[])[]): Node<NodeData>[] | null;
/**
* This function fetches nodes.
*
* @example-ref examples/node/get-1.js
* @example-ref examples/node/get-2.js
* @example-ref examples/node/get-3.js
*
* @param {...(string|object|(string|object)[])} keys to fetch. Each argument could be an id, a path, an object with key and versionId properties or an array of them.
* @param {...(string|object|Array.<(string|object)>)} keys to fetch. Each argument could be an id, a path, an object with key and versionId properties or an array of them.
*
* @returns {object} The node or node array (as JSON) fetched from the repository.
*/
get<NodeData = Record<string, unknown>>(keys: string | GetNodeParams): Node<NodeData> | null;
get<NodeData = Record<string, unknown>>(keys: (string | GetNodeParams)[]): Node<NodeData>[] | null;
get<NodeData = Record<string, unknown>>(...keys: (string | GetNodeParams | (string | GetNodeParams)[])[]): Node<NodeData>[] | null;
get<NodeData = Record<string, unknown>>(...keys: (string | GetNodeParams | (string | GetNodeParams)[])[]): Node<NodeData> | Node<NodeData>[] | null {
const handlerParams = __.newBean<GetNodeHandlerParams>('com.enonic.xp.lib.node.GetNodeHandlerParams');
prepareGetParams(keys, handlerParams);
Expand Down

0 comments on commit 098ecee

Please sign in to comment.