mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Fix node-dogstatsd constructor type definition
As per the documentation the `socket` argument to the constructor is an optional Socket type not a string type. Using a string would result in a fatal error.
This commit is contained in:
7
types/node-dogstatsd/index.d.ts
vendored
7
types/node-dogstatsd/index.d.ts
vendored
@@ -4,7 +4,10 @@
|
||||
// Michael Mifsud <https://github.com/xzyfer>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare module "node-dogstatsd" {
|
||||
import * as dgram from 'dgram';
|
||||
|
||||
export interface StatsDOptions {
|
||||
global_tags?: string[];
|
||||
@@ -25,7 +28,9 @@ declare module "node-dogstatsd" {
|
||||
}
|
||||
|
||||
export class StatsD implements StatsDClient {
|
||||
constructor(host: string, port?: number, socket?: string, options?: StatsDOptions);
|
||||
public socket: dgram.Socket
|
||||
|
||||
constructor(host: string, port?: number, socket?: dgram.Socket, options?: StatsDOptions);
|
||||
|
||||
timing(stat: string, time: number, sample_rate?: number, tags?: string[]): void;
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import * as dgram from 'dgram';
|
||||
import * as datadog from 'node-dogstatsd';
|
||||
|
||||
function test_statsd_client() {
|
||||
// can create client with defaults
|
||||
let client = new datadog.StatsD('localhost');
|
||||
let options: datadog.StatsDOptions = { global_tags: ['environment:definitely_typed']};
|
||||
const socket: dgram.Socket = dgram.createSocket('udp4');
|
||||
|
||||
// can create client with all params
|
||||
client = new datadog.StatsD('localhost', 8125, null, options);
|
||||
client = new datadog.StatsD('localhost', 8125, socket, options);
|
||||
|
||||
let key: string = 'key';
|
||||
let timeValue: number = 99;
|
||||
|
||||
Reference in New Issue
Block a user