question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plugin type definition

See original GitHub issue

Wavesurfer.js version(s)

v4.0.1

Browser and operating system version(s)

Chrome 84.0.4147.125, Windows 10 Pro

Code needed to reproduce the issue

Plugin example from (here)[https://wavesurfer-js.org/example/spectrogram/index.html] seems not working in typescript.

import Wavesurfer from 'wavesurfer.js'
let wavesurefer: Wavesurfer;
wavesurfer = Wavesurfer.create({
  ...
  plugins: [
    Wavesurfer.spectrogram.create({
      fftSamples: 2048,
      ...
    })
  ]
});

I saw PluginDefinitions are well described in index.d.ts as below:

interface PluginDefinition {
  name: String;
  staticProps?: object;
  deferInit?: boolean;
  params: object;
  instance: { new (params: object, ws: WaveSurfer): WaveSurferPlugin };
}

I saw documents and issues, but there are no available informations about name, staticProps and so on.

My question is how to use plugin in typescript, and any example about typescript and plugin would be appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

3reactions
this-username-is-takencommented, Nov 6, 2020

I was able to get the plugins to work with Typescript by doing the following:

  1. Import the plugin directly from the dist folder: import SpectrogramPlugin from 'wavesurfer.js/dist/plugin/wavesurfer.spectrogram';
  2. Use the plugin as described in the docs: var wavesurfer = WaveSurfer.create({ // wavesurfer options ... plugins: [ SpectrogramPlugin.create({ // plugin options ... }) ] });
  3. Turn off TS7016 by adding "noImplicitAny": false to tsconfig.json.

image

Definitely not as ideal as having a proper Typescript definition, but at least I am now able to use the plugins.

1reaction
spicemixcommented, Aug 14, 2021

For examples of how to actually use the plugins etc in Typescript, see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/wavesurfer.js/wavesurfer.js-tests.ts

I personally would not approve any new development that wanted to use Javascript rather than Typescript here in 2021. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin Definitions | Plugin API | Drupal Wiki guide on Drupal.org
Plugins play an integral role in facilitating user interface components. While the plugin system can be used for more situations than this.
Read more >
Plugin types - MoodleDocs
Plugin type Component name (Frankenstyle) Moodle path Activity modules mod /mod Antivirus plugins antivirus /lib/antivirus Assignment submission plugins assignsubmission /mod/assign/submission
Read more >
Define a New Plugin Type - Drupalize.Me
Knowing how to define a new plugin type will allow you to write modules that are more extensible, and more configurable.
Read more >
Module: Plugin - TypeScript: Documentation
Some plugins add or modify top-level exports on existing modules. While this is legal in CommonJS and other loaders, ES6 modules are considered...
Read more >
@xapp/serverless-plugin-type-definitions - npm
serverless-plugin-type-definitions. Typescript definitions that can be used to make Serverless Plugins. Simply import this project and go.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found