Skip to content

Commit

Permalink
fix: update types for TypeScript v2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguttandin committed Mar 28, 2018
1 parent cf9488e commit 47a6536
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/audio-nodes/audio-destination-node.ts
Expand Up @@ -115,7 +115,11 @@ export class AudioDestinationNode implements IAudioDestinationNode {
return this._audioNode.numberOfOutputs;
}

public addEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) {
public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
options?: boolean | AddEventListenerOptions
): void {
return this._audioNode.addEventListener(type, listener, options);
}

Expand All @@ -137,7 +141,11 @@ export class AudioDestinationNode implements IAudioDestinationNode {
return this._audioNode.disconnect(destination);
}

public removeEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) {
public removeEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
options?: EventListenerOptions | boolean
): void {
return this._audioNode.removeEventListener(type, listener, options);
}

Expand Down
12 changes: 10 additions & 2 deletions src/audio-nodes/audio-node.ts
Expand Up @@ -110,7 +110,11 @@ export class AudioNode<T extends INativeAudioNodeFaker | TNativeAudioNode> exten
return this._nativeNode.numberOfOutputs;
}

public addEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) {
public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
options?: boolean | AddEventListenerOptions
): void {
return this._nativeNode.addEventListener(type, listener, options);
}

Expand Down Expand Up @@ -269,7 +273,11 @@ export class AudioNode<T extends INativeAudioNodeFaker | TNativeAudioNode> exten
return this._nativeNode.disconnect(nativeDestinationNode);
}

public removeEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) {
public removeEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
options?: EventListenerOptions | boolean
): void {
return this._nativeNode.removeEventListener(type, listener, options);
}

Expand Down
3 changes: 2 additions & 1 deletion src/audio-param.ts
Expand Up @@ -75,7 +75,8 @@ export class AudioParam implements IAudioParam {
}

public setValueCurveAtTime (values: Float32Array, startTime: number, duration: number) {
this._nativeAudioParam.setValueCurveAtTime(values, startTime, duration);
// @todo TypeScript is expecting values to be an array of numbers.
this._nativeAudioParam.setValueCurveAtTime(<any> values, startTime, duration);
this._audioParamRenderer.record({ duration, startTime, type: 'setValueCurve', values });
}

Expand Down
14 changes: 11 additions & 3 deletions src/event-target.ts
@@ -1,20 +1,28 @@
export class EventTarget {

public addEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) {
public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions
): void {
// @todo Implement the addEventListener() method.
listener; // tslint:disable-line:no-unused-expression
options; // tslint:disable-line:no-unused-expression
type; // tslint:disable-line:no-unused-expression
}

public dispatchEvent (evt: Event) {
public dispatchEvent (evt: Event): boolean {
// @todo Implement the dispatchEvent() method.
evt; // tslint:disable-line:no-unused-expression

return false;
}

public removeEventListener (type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) {
public removeEventListener (
type: string,
listener?: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void {
// @todo Implement the removeEventListener() method.
listener; // tslint:disable-line:no-unused-expression
options; // tslint:disable-line:no-unused-expression
Expand Down
3 changes: 2 additions & 1 deletion src/renderers/audio-param.ts
Expand Up @@ -56,7 +56,8 @@ export class AudioParamRenderer implements IAudioParamRenderer {
} else if (automation.type === 'setValueCurve') {
const { duration, startTime, values } = automation;

audioParam.setValueCurveAtTime(values, startTime, duration);
// @todo TypeScript is expecting values to be an array of numbers.
(<any> audioParam).setValueCurveAtTime(values, startTime, duration);
} else {
throw new Error("Can't apply an unkown automation.");
}
Expand Down

0 comments on commit 47a6536

Please sign in to comment.