mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for node-hook (#45394)
This commit is contained in:
parent
208abc071d
commit
48dcc91662
22
types/node-hook/index.d.ts
vendored
Normal file
22
types/node-hook/index.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Type definitions for node-hook 1.0
|
||||
// Project: https://github.com/bahmutov/node-hook#readme
|
||||
// Definitions by: Nathan Hardy <https://github.com/nhardy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Options {
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
type Transform = (source: string, filename: string) => string;
|
||||
|
||||
interface NodeHook {
|
||||
hook: {
|
||||
(extension: string, transform: Transform, options?: Options): void;
|
||||
(transform: Transform, _?: undefined, options?: Options): void;
|
||||
};
|
||||
unhook(extension?: string): void;
|
||||
}
|
||||
|
||||
declare const hook: NodeHook;
|
||||
|
||||
export = hook;
|
||||
12
types/node-hook/node-hook-tests.ts
Normal file
12
types/node-hook/node-hook-tests.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import hook = require("node-hook");
|
||||
|
||||
function logLoadedFilename(source: string, filename: string) {
|
||||
return `console.log(${JSON.stringify(filename)});\n${source}`;
|
||||
}
|
||||
|
||||
hook.hook(logLoadedFilename);
|
||||
hook.hook(logLoadedFilename, undefined, { verbose: true });
|
||||
hook.hook(".ts", logLoadedFilename);
|
||||
hook.hook(".ts", logLoadedFilename, {});
|
||||
hook.unhook();
|
||||
hook.unhook(".ts");
|
||||
23
types/node-hook/tsconfig.json
Normal file
23
types/node-hook/tsconfig.json
Normal 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",
|
||||
"node-hook-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/node-hook/tslint.json
Normal file
1
types/node-hook/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user