Merge pull request #31642 from BendingBender/signal-exit

[signal-exit] Add types
This commit is contained in:
Wesley Wigham
2018-12-24 21:21:10 -08:00
committed by GitHub
4 changed files with 68 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for signal-exit 3.0
// Project: https://github.com/tapjs/signal-exit
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = signalExit;
declare function signalExit(
callback: (code: number | null, signal: signalExit.Signal | null) => void,
options?: signalExit.Options
): () => void;
declare namespace signalExit {
function load(): void;
function unload(): void;
function signals(): Signal[];
type Signal = 'SIGABRT' | 'SIGALRM' | 'SIGHUP' | 'SIGINT' | 'SIGTERM' | string;
interface Options {
alwaysLast?: boolean;
}
}
+20
View File
@@ -0,0 +1,20 @@
import onExit = require('signal-exit');
// $ExpectType () => void
onExit((code, signal) => {
code; // $ExpectType number | null
signal; // $ExpectType string | null
});
const detach = onExit(
(code, signal) => {
code; // $ExpectType number | null
signal; // $ExpectType string | null
},
{ alwaysLast: true }
);
detach();
onExit.unload();
onExit.load();
onExit.signals(); // $ExpectType string[]
+23
View File
@@ -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",
"signal-exit-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }