chore: Add EventEmitter type to FileObject (#9276)

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
This commit is contained in:
Kukhyeon Heo
2020-12-17 05:46:21 +09:00
committed by GitHub
parent 76a33bb1a1
commit 4ef189e329
3 changed files with 23 additions and 1 deletions

View File

@@ -6,3 +6,24 @@ interface EventEmitter extends EventEmitter2 {
emitMap: (eventName: string, args: any[]) => Array<(...args: any[]) => any>
emitThen: (eventName: string, args: any[]) => Bluebird.BluebirdStatic
}
// Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/events.d.ts
// to avoid type conflict.
interface NodeEventEmitter {
addListener(event: string | symbol, listener: (...args: any[]) => void): this
on(event: string | symbol, listener: (...args: any[]) => void): this
once(event: string | symbol, listener: (...args: any[]) => void): this
removeListener(event: string | symbol, listener: (...args: any[]) => void): this
off(event: string | symbol, listener: (...args: any[]) => void): this
removeAllListeners(event?: string | symbol): this
setMaxListeners(n: number): this
getMaxListeners(): number
listeners(event: string | symbol): Array<(...args: any[]) => void>
rawListeners(event: string | symbol): Array<(...args: any[]) => void>
emit(event: string | symbol, ...args: any[]): boolean
listenerCount(type: string | symbol): number
// Added in Node 6...
prependListener(event: string | symbol, listener: (...args: any[]) => void): this
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
eventNames(): Array<string | symbol>
}

View File

@@ -4970,7 +4970,7 @@ declare namespace Cypress {
dimensions?: Dimensions
}
interface FileObject {
interface FileObject extends NodeEventEmitter {
filePath: string
outputPath: string
shouldWatch: boolean

View File

@@ -28,6 +28,7 @@ const pluginConfig2: Cypress.PluginConfig = (on, config) => {
file.filePath // $ExpectType string
file.outputPath // $ExpectType string
file.shouldWatch // $ExpectType boolean
file.getMaxListeners // $ExpectType () => number
return file.outputPath
})