From 1fc50aa5ac08433c8548c4e6d51d728bb097982e Mon Sep 17 00:00:00 2001 From: mmktomato Date: Wed, 17 Jul 2024 13:59:48 +0900 Subject: [PATCH 1/2] Add type annotation for parameters #90 --- dist/types/backlog.d.ts | 4 ++-- dist/types/option.d.ts | 9 +++++++++ src/backlog.ts | 9 +++++++-- src/option.ts | 10 ++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/dist/types/backlog.d.ts b/dist/types/backlog.d.ts index 112ab30..8eb7d7c 100644 --- a/dist/types/backlog.d.ts +++ b/dist/types/backlog.d.ts @@ -550,7 +550,7 @@ export default class Backlog extends Request { /** * https://developer.nulab.com/docs/backlog/api/2/add-watching */ - postWatchingListItem(params: any): Promise; + postWatchingListItem(params: Option.WatchingList.PostWatchingListItemParams): Promise; /** * https://developer.nulab.com/docs/backlog/api/2/update-watching */ @@ -572,7 +572,7 @@ export default class Backlog extends Request { * https://developer.nulab.com/docs/backlog/api/2/add-project-group * @deprecated */ - postProjectGroup(projectIdOrKey: string | number, params: any): Promise; + postProjectGroup(projectIdOrKey: string | number, params: Option.Group.PostProjectGroupParams): Promise; /** * https://developer.nulab.com/docs/backlog/api/2/delete-project-group * @deprecated diff --git a/dist/types/option.d.ts b/dist/types/option.d.ts index 65d5fb2..d19c37c 100644 --- a/dist/types/option.d.ts +++ b/dist/types/option.d.ts @@ -61,6 +61,12 @@ export declare namespace User { count?: number; } } +export declare namespace WatchingList { + interface PostWatchingListItemParams { + issueIdOrKey: string | number; + note: string; + } +} export declare namespace Group { interface GetGroupsParams { order?: Order; @@ -75,6 +81,9 @@ export declare namespace Group { name?: string; members?: string[]; } + interface PostProjectGroupParams { + groupId: number; + } } export declare namespace Team { interface GetTeamsParams { diff --git a/src/backlog.ts b/src/backlog.ts index 1d48883..1e27cb8 100644 --- a/src/backlog.ts +++ b/src/backlog.ts @@ -1109,7 +1109,9 @@ export default class Backlog extends Request { /** * https://developer.nulab.com/docs/backlog/api/2/add-watching */ - public postWatchingListItem(params: any): Promise { + public postWatchingListItem( + params: Option.WatchingList.PostWatchingListItemParams, + ): Promise { return this.post(`watchings`, params); } @@ -1147,7 +1149,10 @@ export default class Backlog extends Request { * https://developer.nulab.com/docs/backlog/api/2/add-project-group * @deprecated */ - public postProjectGroup(projectIdOrKey: string | number, params: any): Promise { + public postProjectGroup( + projectIdOrKey: string | number, + params: Option.Group.PostProjectGroupParams, + ): Promise { console.warn("Deprecated: Use postProjectTeam instead."); return this.post(`projects/${projectIdOrKey}/groups`, params); } diff --git a/src/option.ts b/src/option.ts index 7aa32a5..9d652ee 100644 --- a/src/option.ts +++ b/src/option.ts @@ -79,6 +79,13 @@ } + export namespace WatchingList { + export interface PostWatchingListItemParams { + issueIdOrKey: string | number; + note: string; + } + } + export namespace Group { export interface GetGroupsParams { @@ -97,6 +104,9 @@ members?: string[]; } + export interface PostProjectGroupParams { + groupId: number; + } } export namespace Team { From 77b7b43c142abe515570ecdfe01815b29cdef714 Mon Sep 17 00:00:00 2001 From: mmktomato Date: Wed, 17 Jul 2024 14:05:12 +0900 Subject: [PATCH 2/2] Deprecate params --- dist/types/option.d.ts | 12 ++++++++++++ src/option.ts | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dist/types/option.d.ts b/dist/types/option.d.ts index d19c37c..9b8974c 100644 --- a/dist/types/option.d.ts +++ b/dist/types/option.d.ts @@ -68,19 +68,31 @@ export declare namespace WatchingList { } } export declare namespace Group { + /** + * @deprecated + */ interface GetGroupsParams { order?: Order; offset?: number; count?: number; } + /** + * @deprecated + */ interface PostGroupsParams { name: string; members?: string[]; } + /** + * @deprecated + */ interface PatchGroupParams { name?: string; members?: string[]; } + /** + * @deprecated + */ interface PostProjectGroupParams { groupId: number; } diff --git a/src/option.ts b/src/option.ts index 9d652ee..b58af1e 100644 --- a/src/option.ts +++ b/src/option.ts @@ -87,23 +87,34 @@ } export namespace Group { - + /** + * @deprecated + */ export interface GetGroupsParams { order?: Order; offset?: number; count?: number; } + /** + * @deprecated + */ export interface PostGroupsParams { name: string; members?: string[]; } + /** + * @deprecated + */ export interface PatchGroupParams { name?: string; members?: string[]; } + /** + * @deprecated + */ export interface PostProjectGroupParams { groupId: number; }