Merge pull request #26869 from stephenmathieson/add-test-listen

add types for test-listen
This commit is contained in:
Paul van Brenk
2018-06-28 11:05:20 -07:00
committed by GitHub
4 changed files with 62 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for test-listen 1.1
// Project: https://github.com/zeit/test-listen
// Definitions by: Stephen Mathieson <https://github.com/stephenmathieson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
import { Server } from "net";
declare function testListen(srv: Server, hostname?: string): Promise<string>;
export = testListen;
+25
View File
@@ -0,0 +1,25 @@
import * as http from 'http';
import testListen = require('test-listen');
const test = async (): Promise<void> => {
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse): void => {
res.write('hello');
res.end();
});
const addr = await testListen(server);
console.log(addr);
};
const testWithHostname = async (): Promise<void> => {
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse): void => {
res.write('hello');
res.end();
});
const addr = await testListen(server, '127.0.0.1');
console.log(addr);
};
test();
testWithHostname();
+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",
"test-listen-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }