bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.16k stars 275 forks source link

Export PeaksInstance interface #485

Closed DavraYoung closed 1 year ago

DavraYoung commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch peaks.js@2.1.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/peaks.js/peaks.js.d.ts b/node_modules/peaks.js/peaks.js.d.ts
index da9907c..6349ea2 100644
--- a/node_modules/peaks.js/peaks.js.d.ts
+++ b/node_modules/peaks.js/peaks.js.d.ts
@@ -443,7 +443,7 @@ declare module 'peaks.js' {
     setZoom: (options: XOR<{ scale: number | 'auto' }, { seconds: number | 'auto' }>) => void;
   }

-  interface PeaksInstance {
+  export interface PeaksInstance {
     setSource: (options: SetSourceOptions, callback: SetSourceCallback) => void;
     destroy: () => void;
     /** Player API */

This issue body was partially generated by patch-package.

chrisn commented 1 year ago

I'm currently importing PeaksInstance into a TypeScript Angular app (code), so how is this working but without export? What problem did this change fix for you?

DavraYoung commented 1 year ago

@chrisn hi. idk why in your case it works as expected. Probably different tsconfig or typescript version, but in my react project typescript resolves this as any and states that PeaksInstance cannot be found in the module. I fixed it by patching the package

chrisn commented 1 year ago

Hi! Thanks, that's curious, I'd be interested to know how it worked without export.