feat(tsc-watch): new type definition v4.2 (#43592)

- definition files
- tests

https://github.com/gilamran/tsc-watch

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-04-06 18:45:04 +02:00 committed by GitHub
parent 6908f6ea06
commit 9a2f620ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 0 deletions

3
types/tsc-watch/client.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import client = require('./lib/client');
export = client;

6
types/tsc-watch/index.d.ts vendored Normal file
View File

@ -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 <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export {};

25
types/tsc-watch/lib/client.d.ts vendored Normal file
View File

@ -0,0 +1,25 @@
/// <reference types="node" />
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;

View File

@ -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.
}

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }