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

refactor(msjs): avoid any (part 1) #13247

Merged
merged 3 commits into from
Feb 12, 2024
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
2 changes: 1 addition & 1 deletion packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,7 @@ type IResponse = operations['i']['responses']['200']['content']['application/jso
type IRevokeTokenRequest = operations['i/revoke-token']['requestBody']['content']['application/json'];

// @public (undocumented)
function isAPIError(reason: any): reason is APIError;
function isAPIError(reason: Record<PropertyKey, unknown>): reason is APIError;

// @public (undocumented)
type ISigninHistoryRequest = operations['i/signin-history']['requestBody']['content']['application/json'];
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
code: string;
message: string;
kind: 'client' | 'server';
info: Record<string, any>;

Check warning on line 17 in packages/misskey-js/src/api.ts

View workflow job for this annotation

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
};

export function isAPIError(reason: any): reason is APIError {
export function isAPIError(reason: Record<PropertyKey, unknown>): reason is APIError {
return reason[MK_API_ERROR] === true;
}

Expand All @@ -29,7 +29,7 @@
headers: { [key in string]: string }
}) => Promise<{
status: number;
json(): Promise<any>;

Check warning on line 32 in packages/misskey-js/src/api.ts

View workflow job for this annotation

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
}>;

export class APIClient {
Expand Down
6 changes: 3 additions & 3 deletions packages/misskey-js/src/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
keyof U
> & U;

type SwitchCase = {
type SwitchCase<Condition = unknown, Result = unknown> = {
$switch: {
$cases: [any, any][],
$default: any;
$cases: [Condition, Result][],
$default: Result;
};
};

Expand All @@ -27,12 +27,12 @@

type IsCaseMatched<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
? IsNeverType<StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>> extends false ? true : false

Check warning on line 30 in packages/misskey-js/src/api.types.ts

View workflow job for this annotation

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
: false

type GetCaseResult<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
? StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>[1]

Check warning on line 35 in packages/misskey-js/src/api.types.ts

View workflow job for this annotation

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
: never

export type SwitchCaseResponseType<E extends keyof Endpoints, P extends Endpoints[E]['req']> = Endpoints[E]['res'] extends SwitchCase
Expand Down
Loading