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

Fix: Fix typescript client #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

SnowSuno
Copy link
Member

@SnowSuno SnowSuno commented May 8, 2022

summary:

  • Add missing type definitions
  • Minor changes to error handling behavior

breaking changes:

  • _postData(): Throw UNKNOWN_ERROR when caught error is not type of AxiosError
  • getUserInfo(): Bubble error instead of returning it directly

summary:
- Add missing type definitions
- Minor changes to error handling behavior

breaking changes:
- _postData(): Throw UNKNOWN_ERROR when caught error is not type of AxiosError
- getUserInfo(): Bubble error instead of returning it directly
@@ -33,7 +33,7 @@ export default class Client {
private readonly URLS: Record<string, string> = {};
private readonly DOMAIN: string;

constructor(clientId, secretKey, isBeta = false, serverAddr = "") {
constructor(clientId: string, secretKey: string, isBeta = false, serverAddr = "") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBeta, serverAddr도 type 적어주세요👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default value를 이와 같이 주면 각각 boolean, string으로 type inference가 되어서 타입 명시는 안 해줬던 것 같네요.
명시적으로 적어주는 것도 나쁘지 않을 것 같긴 해요

client/sparcsssov2-node.ts Outdated Show resolved Hide resolved
throw new Error("NO_PERMISSION");
} else if (err.response.status !== 200) {
throw new Error("UNKNOWN_ERROR");
if (err instanceof AxiosError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@SnowSuno
Copy link
Member Author

후후 1년만에 답글달기

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants