mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
[on-finished] improve typings, enable strict null checks & linting
This commit is contained in:
Vendored
+9
-10
@@ -1,17 +1,16 @@
|
||||
// Type definitions for on-finished v2.2.0
|
||||
// Type definitions for on-finished 2.3
|
||||
// Project: https://github.com/jshttp/on-finished
|
||||
// Definitions by: Honza Dvorsky <http://github.com/czechboy0>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
|
||||
|
||||
declare function onFinished(msg: NodeJS.EventEmitter, listener: Function): NodeJS.EventEmitter;
|
||||
|
||||
declare namespace onFinished {
|
||||
export function isFinished(msg: NodeJS.EventEmitter): boolean;
|
||||
}
|
||||
import { IncomingMessage, OutgoingMessage } from 'http';
|
||||
|
||||
export = onFinished;
|
||||
|
||||
declare function onFinished<T extends IncomingMessage | OutgoingMessage>(msg: T, listener: (err: Error | null, msg: T) => void): T;
|
||||
|
||||
declare namespace onFinished {
|
||||
function isFinished(msg: IncomingMessage | OutgoingMessage): boolean;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import events = require('events');
|
||||
import onFinished = require('on-finished');
|
||||
import { createServer } from 'http';
|
||||
|
||||
function test_finished() {
|
||||
createServer((req, res) => {
|
||||
onFinished(req, (err, req) => {
|
||||
err; // $ExpectType Error | null
|
||||
req; // $ExpectType IncomingMessage
|
||||
});
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
onFinished(res, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType ServerResponse
|
||||
});
|
||||
|
||||
var ret: NodeJS.EventEmitter = onFinished(e, () => {
|
||||
//callback
|
||||
});
|
||||
|
||||
var finished: boolean = onFinished.isFinished(e);
|
||||
}
|
||||
// $ExpectType boolean
|
||||
onFinished.isFinished(req);
|
||||
// $ExpectType boolean
|
||||
onFinished.isFinished(res);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"on-finished-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user