Comparing version 7.0.1 to 7.0.2
interface ResultBase<TValue, TError extends Error> { | ||
hasError: () => this is ResultError<TError>; | ||
hasValue: () => this is ResultValue<TValue>; | ||
hasError: () => this is ResultError<TValue, TError>; | ||
hasValue: () => this is ResultValue<TValue, TError>; | ||
unwrapOrThrow: () => TValue; | ||
@@ -8,15 +8,15 @@ unwrapOrElse: (handleError: (error: Error) => TValue) => TValue; | ||
} | ||
interface ResultError<TError extends Error> extends ResultBase<any, TError> { | ||
interface ResultError<TValue, TError extends Error> extends ResultBase<TValue, TError> { | ||
error: TError; | ||
} | ||
declare const error: <TError extends Error>(err: TError) => ResultError<TError>; | ||
interface ResultValue<TValue> extends ResultBase<TValue, any> { | ||
declare const error: <TValue, TError extends Error>(err: TError) => ResultError<TValue, TError>; | ||
interface ResultValue<TValue, TError extends Error> extends ResultBase<TValue, TError> { | ||
value: TValue; | ||
} | ||
declare const value: { | ||
<TValue extends undefined>(): ResultValue<TValue>; | ||
<TValue>(value: TValue): ResultValue<TValue>; | ||
<TValue extends undefined, TError extends Error>(): ResultValue<TValue, TError>; | ||
<TValue, TError extends Error>(value: TValue): ResultValue<TValue, TError>; | ||
}; | ||
declare type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>; | ||
declare type Result<TValue, TError extends Error> = ResultValue<TValue, TError> | ResultError<TValue, TError>; | ||
export type { ResultValue, ResultError, Result }; | ||
export { value, error }; |
@@ -0,1 +1,8 @@ | ||
## [7.0.2](https://github.com/thenativeweb/defekt/compare/7.0.1...7.0.2) (2021-03-25) | ||
### Bug Fixes | ||
* Add missing TValue and TError generics to constructors. ([#286](https://github.com/thenativeweb/defekt/issues/286)) ([df18c64](https://github.com/thenativeweb/defekt/commit/df18c640c197c8862db68785490b8b7a6d803252)) | ||
## [7.0.1](https://github.com/thenativeweb/defekt/compare/7.0.0...7.0.1) (2021-03-25) | ||
@@ -2,0 +9,0 @@ |
interface ResultBase<TValue, TError extends Error> { | ||
hasError: () => this is ResultError<TError>; | ||
hasValue: () => this is ResultValue<TValue>; | ||
hasError: () => this is ResultError<TValue, TError>; | ||
hasValue: () => this is ResultValue<TValue, TError>; | ||
@@ -10,7 +10,7 @@ unwrapOrThrow: () => TValue; | ||
interface ResultError<TError extends Error> extends ResultBase<any, TError> { | ||
interface ResultError<TValue, TError extends Error> extends ResultBase<TValue, TError> { | ||
error: TError; | ||
} | ||
const error = function <TError extends Error>(err: TError): ResultError<TError> { | ||
const error = function <TValue, TError extends Error>(err: TError): ResultError<TValue, TError> { | ||
return { | ||
@@ -27,6 +27,6 @@ hasError (): boolean { | ||
}, | ||
unwrapOrElse <TValue>(handleError: (error: TError) => TValue): TValue { | ||
unwrapOrElse (handleError: (error: TError) => TValue): TValue { | ||
return handleError(err); | ||
}, | ||
unwrapOrDefault <TValue>(defaultValue: TValue): TValue { | ||
unwrapOrDefault (defaultValue: TValue): TValue { | ||
return defaultValue; | ||
@@ -38,3 +38,3 @@ }, | ||
interface ResultValue<TValue> extends ResultBase<TValue, any> { | ||
interface ResultValue<TValue, TError extends Error> extends ResultBase<TValue, TError> { | ||
value: TValue; | ||
@@ -44,5 +44,5 @@ } | ||
const value: { | ||
<TValue extends undefined>(): ResultValue<TValue>; | ||
<TValue>(value: TValue): ResultValue<TValue>; | ||
} = function <TValue>(val?: TValue): ResultValue<TValue | undefined> { | ||
<TValue extends undefined, TError extends Error>(): ResultValue<TValue, TError>; | ||
<TValue, TError extends Error>(value: TValue): ResultValue<TValue, TError>; | ||
} = function <TValue, TError extends Error>(val?: TValue): ResultValue<TValue | undefined, TError> { | ||
return { | ||
@@ -68,3 +68,3 @@ hasError (): boolean { | ||
type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>; | ||
type Result<TValue, TError extends Error> = ResultValue<TValue, TError> | ResultError<TValue, TError>; | ||
@@ -71,0 +71,0 @@ export type { |
{ | ||
"name": "defekt", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "defekt is custom errors made simple.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27568