Adding TypeScript support for "datadog-winston" (#37983)

* Added typings for datadog-winston

* Updated comments

* Fixing comments which will also kick the Git checks

* Apparently I can't have a PATCH in my version. I thought this was supposed to be the version of the JS package my types target

* Ahh I see now, it is the version of the JS package, just with PATCH omitted

* Updated library to use CommonJS style imports

* Formatting

* Fixing to not use a declare module

* Fixing whitespace

* Fixed typo

* Adding options into a namespace so it can be referenced by consumer
This commit is contained in:
Matthew Hintzke 2019-12-13 11:51:27 -08:00 committed by Ron Buckton
parent 5bd5b2884f
commit e70729bb83
5 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import DatadogWinston = require("datadog-winston");
const options: DatadogWinston.DatadogTransportOptions = {
apiKey: '<key>',
ddsource: 'node.js',
ddtags: 'key:value',
hostname: 'hostname',
level: 'error',
service: 'service',
};
const logger = new DatadogWinston(options);

25
types/datadog-winston/index.d.ts vendored Normal file
View File

@ -0,0 +1,25 @@
// Type definitions for datadog-winston 1.0
// Project: https://github.com/itsfadnis/datadog-winston
// Definitions by: Matt Hintzke <https://github.com/mhintzke13>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import * as Transport from "winston-transport";
declare namespace DatadogWinston {
interface DatadogTransportOptions extends Transport.TransportStreamOptions {
apiKey: string;
hostname?: string;
service?: string;
ddsource?: string;
ddtags?: string;
}
}
declare class DatadogWinston extends Transport {
constructor(options: DatadogWinston.DatadogTransportOptions);
log?(info: any, next: () => void): void;
}
export = DatadogWinston;

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"winston-transport": "^4.3.0"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"datadog-winston-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }