Update gitignore (sorry)
This commit is contained in:
parent
a8f8c4d7ad
commit
cca8b02fea
6604 changed files with 1219661 additions and 4 deletions
36
electron/node_modules/ensure-error/index.d.ts
generated
vendored
Normal file
36
electron/node_modules/ensure-error/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
declare namespace ensureError {
|
||||
interface NonError extends Error {
|
||||
name: 'NonError';
|
||||
}
|
||||
}
|
||||
|
||||
// IfAny<T, ThenType, ElseType> resolves to ThenType if T is `any` and resolves to ElseType otherwise
|
||||
// https://stackoverflow.com/a/49928360/4135063
|
||||
type IfAny<T, ThenType, ElseType> = 0 extends (1 & T) ? ThenType : ElseType;
|
||||
|
||||
/**
|
||||
Ensures a value is a valid error by making it one if not.
|
||||
|
||||
If `input` is an `Error`, any missing `Error` properties will be added.
|
||||
If it's not an `Error`, `input` is converted to an `Error`.
|
||||
|
||||
@example
|
||||
```
|
||||
import ensureError = require('ensure-error');
|
||||
|
||||
const error = new TypeError('🦄');
|
||||
error.name = '';
|
||||
|
||||
console.log(error.name);
|
||||
//=> ''
|
||||
|
||||
console.log(ensureError(error).name);
|
||||
//=> 'TypeError'
|
||||
|
||||
console.log(ensureError(10));
|
||||
//=> [NonError: 10]
|
||||
```
|
||||
*/
|
||||
declare function ensureError<T>(input: T): IfAny<T, Error, T extends Error ? T : ensureError.NonError>;
|
||||
|
||||
export = ensureError;
|
||||
Loading…
Add table
Add a link
Reference in a new issue