acrcloud-node icon indicating copy to clipboard operation
acrcloud-node copied to clipboard

Module isn't declared for typescript usage

Open rennard opened this issue 1 year ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/acrcloud/lib/index.d.ts b/node_modules/acrcloud/lib/index.d.ts
index c01c139..1ffae09 100644
--- a/node_modules/acrcloud/lib/index.d.ts
+++ b/node_modules/acrcloud/lib/index.d.ts
@@ -1,37 +1,47 @@
-type Music = {
-  external_ids: {
-    isrc: string;
-    upc: string;
+declare module "acrcloud" {
+  type Music = {
+    external_ids: {
+      isrc: string;
+      upc: string;
+    };
+    sample_begin_time_offset_ms: string;
+    label: string;
+    play_offset_ms: number;
+    artists: {
+      name: string;
+    }[];
+    release_date: string;
+    title: string;
+    db_end_time_offset_ms: string;
+    duration_ms: number;
+    album: {
+      name: string;
+    };
+    acrid: string;
+    result_from: number;
+    db_begin_time_offset_ms: string;
+    score: number;
   };
-  sample_begin_time_offset_ms: string;
-  label: string;
-  play_offset_ms: number;
-  artists: {
-    name: string;
-  }[];
-  release_date: string;
-  title: string;
-  db_end_time_offset_ms: string;
-  duration_ms: number;
-  album: {
-    name: string;
+  type ACRCloudResponse = {
+    status: {
+      msg: string;
+      code: number;
+      version: string;
+    };
+    metadata: {
+      played_duration: number;
+      music: Music[];
+      timestamp_utc: string;
+    };
+    result_type: number;
+    sample_end_time_offset_ms: string;
   };
-  acrid: string;
-  result_from: number;
-  db_begin_time_offset_ms: string;
-  score: number;
-};
-type ACRCloudResponse = {
-  status: {
-    msg: string;
-    code: number;
-    version: string;
-  };
-  metadata: {
-    played_duration: number;
-    music: Music[];
-    timestamp_utc: string;
-  };
-  result_type: number;
-  sample_end_time_offset_ms: string;
-};
+
+  class ACRCloud {
+    constructor(options: { access_key: string; access_secret: string; host: string });
+    identify(buffer: Buffer): Promise<ACRCloudResponse>;
+  }
+
+  export default ACRCloud;
+}

This issue body was partially generated by patch-package.

rennard avatar Dec 07 '24 22:12 rennard