brussell98 / node-osu

A library for interacting with the osu api.
MIT License
39 stars 11 forks source link

Some typings are incorrect #27

Open cory2067 opened 2 years ago

cory2067 commented 2 years ago

I noticed some issues in index.d.ts that I noticed when integrating node-osu with a typescript project

  1. MultiplayerScore is missing types
  2. Some types are Number but should be number
  3. Types assume that parseNumeric is true, because the numeric fields are always number. However, if parseNumeric is false (the default), then those types are wrong.

To resolve 1 and 2 for my use case, I applied the following patch locally:

diff --git a/node_modules/node-osu/index.d.ts b/node_modules/node-osu/index.d.ts
index 0c587eb..317386a 100644
--- a/node_modules/node-osu/index.d.ts
+++ b/node_modules/node-osu/index.d.ts
@@ -218,8 +218,23 @@ export class Game {
 }

 export class MultiplayerScore {
-    constructor(...args: any[]);
-
+    slot: number;
+    team: string;
+    userId: string;
+    score: number;
+    maxCombo: string;
+    counts: {
+        '300': number,
+        '100': number,
+        '50': number,
+        'geki': number,
+        'katu': number,
+        'miss': number
+    }
+    perfect: boolean;
+    pass: boolean;
+    raw_mods: number;
+    mods: string[];
 }

 export class Score {
@@ -274,9 +289,9 @@ export class User {
         total: number;
     };
     pp: {
-        raw: Number,
-        rank: Number,
-        countryRank: Number
+        raw: number,
+        rank: number,
+        countryRank: number
     };
     country: string;
     level: number;

This issue body was partially generated by patch-package.