mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[console-log-level] initial types (#27506)
* [console-log-level] initial types * [squash] address review feedback * [squash] export more types in namespace
This commit is contained in:
parent
1dc66757c0
commit
045d74baf3
20
types/console-log-level/console-log-level-tests.ts
Normal file
20
types/console-log-level/console-log-level-tests.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import consoleLogLevel = require("console-log-level");
|
||||
|
||||
const logger1 = consoleLogLevel({
|
||||
level: "trace",
|
||||
stderr: undefined,
|
||||
prefix: () => "SOME PREFIX"
|
||||
});
|
||||
|
||||
const logger2 = consoleLogLevel({
|
||||
level: "trace",
|
||||
stderr: true,
|
||||
prefix: "OTHER PREFIX"
|
||||
});
|
||||
|
||||
logger1.trace("hello %s", "world");
|
||||
logger2.debug("hello %s", "world");
|
||||
logger2.info("hello %s", "world");
|
||||
logger2.warn("hello %s", "world");
|
||||
logger2.error("hello %s", "world");
|
||||
logger2.fatal("hello %s", "world");
|
||||
23
types/console-log-level/index.d.ts
vendored
Normal file
23
types/console-log-level/index.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Type definitions for console-log-level 1.4
|
||||
// Project: https://github.com/watson/console-log-level
|
||||
// Definitions by: Ali Ijaz Sheikh <https://github.com/ofrobots>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
type PrefixFunction = (level: string) => string;
|
||||
|
||||
declare namespace consoleLogLevel {
|
||||
type LogLevelNames =
|
||||
"trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
||||
type Logger = Record<LogLevelNames, (...args: any[]) => void>;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
level?: consoleLogLevel.LogLevelNames;
|
||||
prefix?: string | PrefixFunction;
|
||||
stderr?: boolean;
|
||||
}
|
||||
|
||||
declare function consoleLogLevel(opts: Options): consoleLogLevel.Logger;
|
||||
|
||||
export = consoleLogLevel;
|
||||
23
types/console-log-level/tsconfig.json
Normal file
23
types/console-log-level/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"console-log-level-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/console-log-level/tslint.json
Normal file
1
types/console-log-level/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user