From 9a2f620ce7cecb7398bcb7a97d4c7d02efd26ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Mon, 6 Apr 2020 18:45:04 +0200 Subject: [PATCH] feat(tsc-watch): new type definition v4.2 (#43592) - definition files - tests https://github.com/gilamran/tsc-watch Thanks! --- types/tsc-watch/client.d.ts | 3 +++ types/tsc-watch/index.d.ts | 6 ++++++ types/tsc-watch/lib/client.d.ts | 25 +++++++++++++++++++++++++ types/tsc-watch/tsc-watch-tests.ts | 22 ++++++++++++++++++++++ types/tsc-watch/tsconfig.json | 23 +++++++++++++++++++++++ types/tsc-watch/tslint.json | 1 + 6 files changed, 80 insertions(+) create mode 100644 types/tsc-watch/client.d.ts create mode 100644 types/tsc-watch/index.d.ts create mode 100644 types/tsc-watch/lib/client.d.ts create mode 100644 types/tsc-watch/tsc-watch-tests.ts create mode 100644 types/tsc-watch/tsconfig.json create mode 100644 types/tsc-watch/tslint.json 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" }