diff --git a/types/fb-watchman/fb-watchman-tests.ts b/types/fb-watchman/fb-watchman-tests.ts new file mode 100644 index 0000000000..9b1aeb387b --- /dev/null +++ b/types/fb-watchman/fb-watchman-tests.ts @@ -0,0 +1,14 @@ +import { Client } from "fb-watchman"; + +const client = new Client(); +const clientB = new Client({}); + +client.capabilityCheck({ optional: [], required: ['relative_root'] }, e => { + if (e) { + client.end(); + return; + } +}); +client.connect(); + +client.command(['watch-project', '/tmp'], () => {}); diff --git a/types/fb-watchman/index.d.ts b/types/fb-watchman/index.d.ts new file mode 100644 index 0000000000..a009cbe247 --- /dev/null +++ b/types/fb-watchman/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for fb-watchman 2.0 +// Project: https://facebook.github.io/watchman/ +// Definitions by: Wu Haotian +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { EventEmitter } from 'events'; + +// Emit the responses to these when they get sent down to us +export type UnilateralTags = 'unilateralTags' | 'log'; + +export interface ClientOptions { + /** + * Absolute path to the watchman binary. + * If not provided, the Client locates the binary using the PATH specified + * by the node child_process's default env. + */ + watchmanBinaryPath?: string; +} + +export interface Capabilities { + optional: any[]; + required: any[]; +} + +export type doneCallback = (error?: Error | null, resp?: any) => any; + +export class Client extends EventEmitter { + constructor(options?: ClientOptions) + sendNextCommand(): void; + cancelCommands(why: string): void; + connect(): void; + command(args: any, done: doneCallback): void; + capabilityCheck( + caps: Capabilities, + done: doneCallback, + ): void; + end(): void; +} diff --git a/types/fb-watchman/tsconfig.json b/types/fb-watchman/tsconfig.json new file mode 100644 index 0000000000..83ad2335ea --- /dev/null +++ b/types/fb-watchman/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fb-watchman-tests.ts" + ] +} diff --git a/types/fb-watchman/tslint.json b/types/fb-watchman/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fb-watchman/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }