Skip to content

Commit

Permalink
fix: blur EventTarget definition to support TypeScript v2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguttandin committed Mar 28, 2018
1 parent 983f4ae commit 4e9c4b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/audio-nodes/audio-destination-node.ts
Expand Up @@ -117,7 +117,7 @@ export class AudioDestinationNode implements IAudioDestinationNode {

public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: boolean | AddEventListenerOptions
): void {
return this._audioNode.addEventListener(type, listener, options);
Expand All @@ -143,7 +143,7 @@ export class AudioDestinationNode implements IAudioDestinationNode {

public removeEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: EventListenerOptions | boolean
): void {
return this._audioNode.removeEventListener(type, listener, options);
Expand Down
4 changes: 2 additions & 2 deletions src/audio-nodes/audio-node.ts
Expand Up @@ -112,7 +112,7 @@ export class AudioNode<T extends INativeAudioNodeFaker | TNativeAudioNode> exten

public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: boolean | AddEventListenerOptions
): void {
return this._nativeNode.addEventListener(type, listener, options);
Expand Down Expand Up @@ -275,7 +275,7 @@ export class AudioNode<T extends INativeAudioNodeFaker | TNativeAudioNode> exten

public removeEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null = null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: EventListenerOptions | boolean
): void {
return this._nativeNode.removeEventListener(type, listener, options);
Expand Down
4 changes: 2 additions & 2 deletions src/event-target.ts
Expand Up @@ -2,7 +2,7 @@ export class EventTarget {

public addEventListener (
type: string,
listener: EventListenerOrEventListenerObject | null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: boolean | AddEventListenerOptions
): void {
// @todo Implement the addEventListener() method.
Expand All @@ -20,7 +20,7 @@ export class EventTarget {

public removeEventListener (
type: string,
listener?: EventListenerOrEventListenerObject | null,
listener: any, // @todo EventListenerOrEventListenerObject | null = null,
options?: EventListenerOptions | boolean
): void {
// @todo Implement the removeEventListener() method.
Expand Down
12 changes: 10 additions & 2 deletions src/interfaces/native-constant-source-node.ts
Expand Up @@ -12,14 +12,22 @@ export interface INativeConstantSourceNode extends AudioNode {
listener: (this: OscillatorNode, ev: INativeConstantSourceNodeMap[K]) => any,
options?: boolean | AddEventListenerOptions
): void;
addEventListener (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
addEventListener (
type: string,
listener: any, // @todo EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions
): void;

removeEventListener <K extends keyof INativeConstantSourceNodeMap> (
type: K,
listener: (this: OscillatorNode, ev: INativeConstantSourceNodeMap[K]) => any,
options?: boolean | EventListenerOptions
): void;
removeEventListener (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
removeEventListener (
type: string,
listener: any, // @todo EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions
): void;

start (when?: number): void;

Expand Down
Expand Up @@ -22,11 +22,11 @@ export class AudioScheduledSourceNodeStopMethodConsecutiveCallsWrapper {
const disconnectGainNode = ((disconnect) => {
return () => {
disconnect.call(audioScheduledSourceNode, gainNode);
audioScheduledSourceNode.removeEventListener('ended', disconnectGainNode);
(<any> audioScheduledSourceNode).removeEventListener('ended', disconnectGainNode);
};
})(audioScheduledSourceNode.disconnect);

audioScheduledSourceNode.addEventListener('ended', disconnectGainNode);
(<any> audioScheduledSourceNode).addEventListener('ended', disconnectGainNode);

audioScheduledSourceNode.connect = ((destination: TNativeAudioNode | TNativeAudioParam, output = 0, input = 0) => {
if (destination instanceof AudioNode) {
Expand Down

0 comments on commit 4e9c4b1

Please sign in to comment.