From 47f0b61b3811811a478399050367eb59819354d3 Mon Sep 17 00:00:00 2001 From: Mehrdad Reshadi Date: Sat, 24 Jun 2017 04:04:37 -0700 Subject: [PATCH 1/2] added more expressive types to jake to better match the actual js code --- types/jake/index.d.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/types/jake/index.d.ts b/types/jake/index.d.ts index cb23f992f0..da21441a5a 100644 --- a/types/jake/index.d.ts +++ b/types/jake/index.d.ts @@ -38,7 +38,7 @@ declare function fail(...err:any[]): void; * @param action The action to perform for this task * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. */ -declare function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask; +declare function file(name:string, prereqs?:string[], action?:(this: jake.FileTask)=>void, opts?:jake.FileTaskOptions): jake.FileTask; /** * Creates Jake FileTask from regex patterns @@ -63,9 +63,9 @@ declare function namespace(name:string, scope:()=>void): void; * @param action The action to perform for this task * @param opts */ -declare function task(name:string, prereqs?:string[], action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; -declare function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; -declare function task(name:string, opts?:jake.TaskOptions, action?:(...params:any[])=>any): jake.Task; +declare function task(name:string, prereqs?:string[], action?:(this: jake.Task, ...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +declare function task(name:string, action?:(this: jake.Task, ...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +declare function task(name:string, opts?:jake.TaskOptions, action?:(this: jake.Task, ...params:any[])=>any): jake.Task; /** * @param name The name of the NpmPublishTask @@ -214,7 +214,7 @@ declare namespace jake{ * @param action The action to perform for this task * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. */ - constructor(name:string, prereqs?:string[], action?:()=>void, opts?:TaskOptions); + constructor(name:string, prereqs?:string[], action?:(this: Task)=>void, opts?:TaskOptions); /** * Runs prerequisites, then this task. If the task has already been run, will not run the task again. @@ -236,10 +236,19 @@ declare namespace jake{ listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; listenerCount(type: string): number; + complete(value): void; value: any; + + name?: string; + prereqs?: string[]; + action?: (...params: any[]) => any; + taskStatus?: string; + async?: boolean; + description?: string; + fullName: string; } - export class DirectoryTask{ + export class DirectoryTask extends FileTask { /** * @param name The name of the directory to create. */ @@ -254,14 +263,14 @@ declare namespace jake{ async?: boolean; } - export class FileTask{ + export class FileTask extends Task{ /** * @param name The name of the Task * @param prereqs Prerequisites to be run before this task * @param action The action to perform to create this file * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. */ - constructor(name:string, prereqs?:string[], action?:()=>void, opts?:FileTaskOptions); + constructor(name:string, prereqs?:string[], action?:(this: FileTask)=>void, opts?:FileTaskOptions); } interface FileFilter{ From 940c77c8e5f9648b88d4686b153ebe22af407852 Mon Sep 17 00:00:00 2001 From: Mehrdad Reshadi Date: Sat, 24 Jun 2017 04:20:14 -0700 Subject: [PATCH 2/2] Update index.d.ts --- types/jake/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jake/index.d.ts b/types/jake/index.d.ts index da21441a5a..98fc72d148 100644 --- a/types/jake/index.d.ts +++ b/types/jake/index.d.ts @@ -236,7 +236,7 @@ declare namespace jake{ listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; listenerCount(type: string): number; - complete(value): void; + complete(value?: any): void; value: any; name?: string;