diff --git a/types/tsc-watch/client.d.ts b/types/tsc-watch/client.d.ts new file mode 100644 index 0000000000..7a73a0871c --- /dev/null +++ b/types/tsc-watch/client.d.ts @@ -0,0 +1,3 @@ +import client = require('./lib/client'); + +export = client; diff --git a/types/tsc-watch/index.d.ts b/types/tsc-watch/index.d.ts new file mode 100644 index 0000000000..5918c7a0a9 --- /dev/null +++ b/types/tsc-watch/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for tsc-watch 4.2 +// Project: https://github.com/gilamran/tsc-watch#readme +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export {}; diff --git a/types/tsc-watch/lib/client.d.ts b/types/tsc-watch/lib/client.d.ts new file mode 100644 index 0000000000..fcee84caaa --- /dev/null +++ b/types/tsc-watch/lib/client.d.ts @@ -0,0 +1,25 @@ +/// + +import { EventEmitter } from 'events'; + +declare class TscWatchClient extends EventEmitter { + start(...args: any[]): void; + kill(): void; + + // tslint:disable:unified-signatures + /** + * Emitted upon first successful compilation + */ + on(event: 'first_success', cb: () => any): this; + /** + * Emitted upon first successful compilation + */ + on(event: 'success', cb: () => any): this; + /** + * Emitted upon every failing compilation + */ + on(event: 'compile_errors', cb: () => any): this; + // tslint:enable:unified-signatures +} + +export = TscWatchClient; diff --git a/types/tsc-watch/tsc-watch-tests.ts b/types/tsc-watch/tsc-watch-tests.ts new file mode 100644 index 0000000000..492931e76c --- /dev/null +++ b/types/tsc-watch/tsc-watch-tests.ts @@ -0,0 +1,22 @@ +import TscWatchClient = require('tsc-watch/client'); +const watch = new TscWatchClient(); + +watch.on('first_success', () => { + console.log('First success!'); +}); + +watch.on('success', () => { + // Your code goes here... +}); + +watch.on('compile_errors', () => { + // Your code goes here... +}); + +watch.start('--project', '.'); + +try { + // do something... +} catch (e) { + watch.kill(); // Fatal error, kill the compiler instance. +} diff --git a/types/tsc-watch/tsconfig.json b/types/tsc-watch/tsconfig.json new file mode 100644 index 0000000000..efbfe4f554 --- /dev/null +++ b/types/tsc-watch/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tsc-watch-tests.ts" + ] +} diff --git a/types/tsc-watch/tslint.json b/types/tsc-watch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/tsc-watch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }