Merge pull request #32527 from npenin/master

updating debug to be compilable in TS > 3.1
This commit is contained in:
Pranav Senthilnathan
2019-02-07 11:11:41 -08:00
committed by GitHub
3 changed files with 38 additions and 104 deletions
+16 -11
View File
@@ -1,26 +1,31 @@
import * as debug1 from "debug";
/*tslint:disable-next-line:no-duplicate-imports*/
import debug2 from 'debug';
const log2: debug1.Debugger = debug2("DefinitelyTyped:log");
log2("Just text");
log2("Formatted test (%d arg)", 1);
log2("Formatted %s (%d args)", "test", 2);
import debug = require("debug");
debug1.disable();
debug1.enable("DefinitelyTyped:*");
debug.disable();
debug.enable("DefinitelyTyped:*");
var log:debug.IDebugger = debug("DefinitelyTyped:log");
const log: debug1.Debugger = debug1("DefinitelyTyped:log");
log("Just text");
log("Formatted test (%d arg)", 1);
log("Formatted %s (%d args)", "test", 2);
log("Enabled?: %s", debug.enabled("DefinitelyTyped:log"));
log("Name Enabled: %s", debug.names.some(name => name.test("DefinitelyTyped:log")));
log("Enabled?: %s", debug1.enabled("DefinitelyTyped:log"));
log("Name Enabled: %s", debug1.names.some(name => name.test("DefinitelyTyped:log")));
log("Namespace: %s", log.namespace);
var error:debug.IDebugger = debug("DefinitelyTyped:error");
const error: debug1.Debugger = debug1("DefinitelyTyped:error");
error.log = console.error.bind(console);
error("This should be printed to stderr");
var extendedLog: debug.IDebugger = log.extend('extended');
const extendedLog: debug1.Debugger = log.extend('extended');
extendedLog("Testing this is also an IDebugger.");
var extendedWithCustomDelimiter: debug.IDebugger = log.extend('with-delim', '.');
extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
const extendedWithCustomDelimiter: debug1.Debugger = log.extend('with-delim', '.');
extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
+21 -16
View File
@@ -1,40 +1,45 @@
// Type definitions for debug
// Type definitions for debug 4.1
// Project: https://github.com/visionmedia/debug
// Definitions by: Seon-Wook Park <https://github.com/swook>
// Gal Talmor <https://github.com/galtalmor>
// John McLaughlin <https://github.com/zamb3zi>
// Brasten Sager <https://github.com/brasten>
// Nicolas Penin <https://github.com/npenin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var debug: debug.IDebug;
declare var debug: debug.Debug & {debug: debug.Debug, default: debug.Debug};
export = debug;
export as namespace debug;
declare namespace debug {
export interface IDebug {
(namespace: string): debug.IDebugger,
coerce: (val: any) => any,
disable: () => void,
enable: (namespaces: string) => void,
enabled: (namespaces: string) => boolean,
interface Debug {
(namespace: string): Debugger;
coerce: (val: any) => any;
disable: () => void;
enable: (namespaces: string) => void;
enabled: (namespaces: string) => boolean;
names: RegExp[],
skips: RegExp[],
names: RegExp[];
skips: RegExp[];
formatters: IFormatters
formatters: Formatters;
}
export interface IFormatters {
[formatter: string]: Function
type IDebug = Debug;
interface Formatters {
[formatter: string]: (v: any) => string;
}
export interface IDebugger {
type IDebugger = Debugger;
interface Debugger {
(formatter: any, ...args: any[]): void;
enabled: boolean;
log: Function;
log: (v: any) => string;
namespace: string;
extend: (namespace: string, delimiter?: string) => debug.IDebugger;
extend: (namespace: string, delimiter?: string) => Debugger;
}
}
+1 -77
View File
@@ -1,79 +1,3 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
"extends": "dtslint/dt.json"
}