Use function overloading to provide stricter parameter restrictions

This commit is contained in:
YXL 2020-09-30 14:59:52 +08:00
parent 85ea2d8934
commit bfafe19352

70
main.d.ts vendored
View File

@ -349,10 +349,55 @@ declare module 'NeteaseCloudMusicApi' {
params: { params: {
id: string | number id: string | number
type: CommentType type: CommentType
t: CommentAction t: CommentAction.delete
threadId?: string commentId: string | number
content?: string | number } & RequestBaseConfig,
commentId?: string | number ): Promise<Response>
export function comment(
params: {
type: CommentType.event
t: CommentAction.delete
threadId: string
commentId: string | number
} & RequestBaseConfig,
): Promise<Response>
export function comment(
params: {
id: string | number
type: CommentType
t: CommentAction.add
content: string | number
} & RequestBaseConfig,
): Promise<Response>
export function comment(
params: {
type: CommentType.event
t: CommentAction.add
threadId: string
content: string | number
} & RequestBaseConfig,
): Promise<Response>
export function comment(
params: {
id: string | number
type: CommentType
t: CommentAction.reply
content: string | number
commentId: string | number
} & RequestBaseConfig,
): Promise<Response>
export function comment(
params: {
type: CommentType.event
t: CommentAction.reply
threadId: string
content: string | number
commentId: string | number
} & RequestBaseConfig, } & RequestBaseConfig,
): Promise<Response> ): Promise<Response>
@ -681,10 +726,18 @@ declare module 'NeteaseCloudMusicApi' {
): Promise<Response> ): Promise<Response>
export function login( export function login(
params: { email: string; password: string } & RequestBaseConfig,
): Promise<Response>
export function login(
params: { email: string; md5_password: string } & RequestBaseConfig,
): Promise<Response>
export function login_cellphone(
params: { params: {
email: string phone: string
password?: string countrycode?: string
md5_password?: string password: string
} & RequestBaseConfig, } & RequestBaseConfig,
): Promise<Response> ): Promise<Response>
@ -692,8 +745,7 @@ declare module 'NeteaseCloudMusicApi' {
params: { params: {
phone: string phone: string
countrycode?: string countrycode?: string
password?: string md5_password: string
md5_password?: string
} & RequestBaseConfig, } & RequestBaseConfig,
): Promise<Response> ): Promise<Response>