mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #26869 from stephenmathieson/add-test-listen
add types for test-listen
This commit is contained in:
Vendored
+13
@@ -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;
|
||||
@@ -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();
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user