Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Feb 24, 2024
1 parent 927310c commit a96f3ce
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/base-provider.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
default_attribute
} from "./attributes.mjs";

/**
* @typedef {import('./project.mjs').Project} Project
* @typedef {import('./milestone.mjs').Milestone} Milestone
*/
/**
* @typedef {import('./project.mjs').Project} Project
* @typedef {import('./milestone.mjs').Milestone} Milestone
*/

/**
* @typedef {Object} MessageDestination
Expand Down Expand Up @@ -143,6 +143,11 @@ export class BaseProvider extends BaseObject {
return 0;
}

/**
* @typedef {Object} parsedName
*
*/

/**
* Creates a new provider for a given set of options.
* @param {Object} options additional options
Expand All @@ -163,7 +168,7 @@ export class BaseProvider extends BaseObject {
}

/**
* @param {any} other
* @param {any} other
* @return {boolean} true if other provider is the same as the receiver
*/
equals(other) {
Expand Down Expand Up @@ -199,11 +204,11 @@ export class BaseProvider extends BaseObject {
* Like .git suffix or #branch names.
* @param {string} name
* @param {boolean} forLookup
* @return {string} normalized name
* @return {string|undefined} normalized name
*/
normalizeRepositoryName(name, forLookup) {
const { repository } = this.parseName(name);
return forLookup && !this.areRepositoryNamesCaseSensitive
return repository && forLookup && !this.areRepositoryNamesCaseSensitive
? repository.toLowerCase()
: repository;
}
Expand All @@ -213,7 +218,7 @@ export class BaseProvider extends BaseObject {
* Like .git suffix or #branch names.
* @param {string} name
* @param {boolean} forLookup
* @return {string} normalized name
* @return {string|undefined} normalized name
*/
normalizeGroupName(name, forLookup) {
const { group } = this.parseName(name, "group");
Expand Down Expand Up @@ -245,12 +250,13 @@ export class BaseProvider extends BaseObject {
* base, group, repository and branch.
* @param {string} [name]
* @param {string} focus where lies the focus if only one path component is given
* @return {Object} with separated attributes
* @return {{base: string|undefined, group: string|undefined, repository: string|undefined, branch: string|undefined}} with separated attributes
*/
parseName(name, focus = "repository") {
const result = {};

if (name === undefined) {
// @ts-ignore
return result;
}

Expand Down Expand Up @@ -295,6 +301,7 @@ export class BaseProvider extends BaseObject {
}
}

// @ts-ignore
return result;
}

Expand All @@ -310,7 +317,7 @@ export class BaseProvider extends BaseObject {
const rg = await this.repositoryGroup(group);
return rg.createRepository(repository, options);
}

/**
* List provider objects of a given type.
*
Expand Down Expand Up @@ -343,7 +350,7 @@ export class BaseProvider extends BaseObject {
/**
* List projects.
* @param {string[]|string} [patterns]
* @return {AsyncIterator<Project>} all matching projects of the provider
* @return {AsyncIterable<Project>} all matching projects of the provider
*/
async *projects(patterns) {
// @ts-ignore
Expand All @@ -353,7 +360,7 @@ export class BaseProvider extends BaseObject {
/**
* List milestones.
* @param {string[]|string} [patterns]
* @return {AsyncIterator<Milestone>} all matching milestones of the provider
* @return {AsyncIterable<Milestone>} all matching milestones of the provider
*/
async *milestones(patterns) {
// @ts-ignore
Expand Down Expand Up @@ -428,7 +435,7 @@ export class BaseProvider extends BaseObject {

/**
* List all defined entries from attributes.
* return {object}
* @return {object}
*/
toJSON() {
const json = { name: this.name };
Expand Down

0 comments on commit a96f3ce

Please sign in to comment.