mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #50993 [avocat] add initial types by @timcosta
This commit is contained in:
10
types/avocat/avocat-tests.ts
Normal file
10
types/avocat/avocat-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as Avocat from 'avocat';
|
||||
import * as Boom from '@hapi/boom';
|
||||
|
||||
const notFound: Boom.Boom = Avocat.rethrow(Boom.notFound(), { return: true });
|
||||
notFound.message;
|
||||
Avocat.rethrow(Boom.badImplementation(), { includeMessage: true });
|
||||
|
||||
try {
|
||||
Avocat.rethrow(Boom.conflict());
|
||||
} catch (e) {}
|
||||
19
types/avocat/index.d.ts
vendored
Normal file
19
types/avocat/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for avocat 2.0
|
||||
// Project: https://github.com/hapipal/avocat#readme
|
||||
// Definitions by: Tim Costa <https://github.com/timcosta>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { ResponseObject } from '@hapi/hapi';
|
||||
import { Boom } from '@hapi/boom';
|
||||
|
||||
export interface Options {
|
||||
return?: boolean;
|
||||
includeMessage?: boolean;
|
||||
}
|
||||
|
||||
// the return type has to be any because the following scenarios exist:
|
||||
// 1. options.return = false - this will always throw or return false
|
||||
// 2. options.return = true - this will either return false or a Boom type
|
||||
// Due to scenario 2 and that behavior changes based on options, a return
|
||||
// type of any is the only way I see this working
|
||||
export function rethrow(err: ResponseObject | Boom, options?: Options): any;
|
||||
6
types/avocat/package.json
Normal file
6
types/avocat/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@hapi/boom": "^9.1.1"
|
||||
}
|
||||
}
|
||||
26
types/avocat/tsconfig.json
Normal file
26
types/avocat/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@hapi/*": [ "hapi__*" ]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"avocat-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/avocat/tslint.json
Normal file
1
types/avocat/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user