mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #31642 from BendingBender/signal-exit
[signal-exit] Add types
This commit is contained in:
Vendored
+24
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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[]
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user