TypeScript: AudioWorkletProcessor type definition is missing
TypeScript Version: 3.2.0-dev.201xxxxx
Search Terms: AudioWorkletProcessor
You guys have type definitions for AudioWorkletNode and such but missed the definition for AudioWorkletProcessor as per: https://webaudio.github.io/web-audio-api/#audioworkletprocessor
This is what I have for now:
interface AudioWorkletProcessor {
readonly port: MessagePort;
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Map<string, Float32Array>): void;
}
declare var AudioWorkletProcessor: {
prototype: AudioWorkletProcessor;
new(options?: AudioWorkletNodeOptions): AudioWorkletProcessor;
}
Cheers
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 37
- Comments: 22 (7 by maintainers)
I think the typescript DOM lib generator publishes this to package @types/audioworklet but that needs to be manually added to your package.json
The definition of
registerProcessorwas missing as well.I’m using the following definitions:
EDIT: added the parameter descriptors to the registerProcessor() declaration.
Install
@types/audioworkletAdd
@ types/audioworkletto thetsconfig. jsonfile to work for me.Add correct return type to avoid implicit any warnings. https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope/registerProcessor#return_value
Unfortunately,
@types/audioworkletonly works if you aren’t usingDOMat the same time because of definition conflicts.I get an error because the optional
optionsconstructor parameter is missing entirely from that definition. It’s present in the handwritten versions further up the thread. Surprising that was overlooked.Working on Web Audio API library I was surprised it’s missing in TS. Most of other stuff, including other Audio Worklet related classes/interfaces are present.
@navelpluisje
parameters: Record<string, Float32Array>should also work.