Skip to content

Commit b082106

Browse files
mathe42saschanaz
andauthored
fix: audioworklet registerProcessor should expect a constructor not a function (microsoft#1296)
Co-authored-by: saschanaz <[email protected]>
1 parent 77839d4 commit b082106

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

baselines/audioworklet.generated.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ declare var AudioWorkletProcessor: {
217217
new(): AudioWorkletProcessor;
218218
};
219219

220+
interface AudioWorkletProcessorImpl extends AudioWorkletProcessor {
221+
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
222+
}
223+
220224
/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */
221225
interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> {
222226
readonly highWaterMark: number;
@@ -891,7 +895,7 @@ declare namespace WebAssembly {
891895
}
892896

893897
interface AudioWorkletProcessorConstructor {
894-
(options: any): AudioWorkletProcessor;
898+
new (options: any): AudioWorkletProcessorImpl;
895899
}
896900

897901
interface PerformanceObserverCallback {

inputfiles/addedTypes.jsonc

+16
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,22 @@
338338
},
339339
"interfaces": {
340340
"interface": {
341+
"AudioWorkletProcessorImpl": {
342+
"name": "AudioWorkletProcessorImpl",
343+
"extends": "AudioWorkletProcessor",
344+
"methods": {
345+
"method": {
346+
"process": {
347+
"name": "process",
348+
"overrideSignatures": [
349+
"process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean"
350+
]
351+
}
352+
}
353+
},
354+
"exposed": "AudioWorklet",
355+
"noInterfaceObject": true
356+
},
341357
"BroadcastChannel": {
342358
"events": {
343359
"event": [

inputfiles/overridingTypes.jsonc

+5
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@
366366
"overrideSignatures": [
367367
"new (...params: any[]): HTMLElement"
368368
]
369+
},
370+
"AudioWorkletProcessorConstructor": {
371+
"overrideSignatures": [
372+
"new (options: any): AudioWorkletProcessorImpl"
373+
]
369374
}
370375
}
371376
},
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"lib": ["es2020"],
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"strict": true,
8+
"esModuleInterop": true,
9+
"sourceMap": true,
10+
"noUnusedLocals": true,
11+
"noUnusedParameters": true
12+
},
13+
"include": [
14+
"../../../baselines/audioworklet*",
15+
"**/*"
16+
]
17+
}

unittests/files/audioworklet/usage.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
registerProcessor(
2+
"test",
3+
class extends AudioWorkletProcessor {
4+
process(input: Float32Array[][], output: Float32Array[][], params: { [key: string]: Float32Array }) {
5+
return true;
6+
}
7+
}
8+
);

unittests/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ for (const filename of await readdir(new URL("files/", import.meta.url))) {
88
});
99
}
1010
}
11+
12+
for (const filename of await readdir(new URL("files/audioworklet", import.meta.url))) {
13+
if (filename.endsWith(".ts")) {
14+
execSync(`npx tsc generated/audioworklet.generated.d.ts unittests/files/audioworklet/${filename} --target es2020 --lib es2020 --types --noEmit`, {
15+
stdio: "inherit"
16+
});
17+
}
18+
}

0 commit comments

Comments
 (0)