Comparing version 7.3.0 to 7.3.1
interface ResultBase<TValue, TError extends Error> { | ||
hasError: () => this is ResultError<TError>; | ||
hasValue: () => this is ResultValue<TValue>; | ||
hasError: () => this is ResultError<TError> & ResultBase<any, TError>; | ||
hasValue: () => this is ResultValue<TValue> & ResultBase<TValue, any>; | ||
unwrapOrThrow: (errorTransformer?: (err: TError) => Error) => TValue; | ||
@@ -8,15 +8,15 @@ unwrapOrElse: (handleError: (error: Error) => TValue) => TValue; | ||
} | ||
interface ResultError<TError extends Error> extends ResultBase<unknown, TError> { | ||
interface ResultError<TError extends Error> { | ||
error: TError; | ||
} | ||
declare const error: <TError extends Error>(err: TError) => ResultError<TError>; | ||
interface ResultValue<TValue> extends ResultBase<TValue, Error> { | ||
declare const error: <TError extends Error>(err: TError) => ResultError<TError> & ResultBase<any, TError>; | ||
interface ResultValue<TValue> { | ||
value: TValue; | ||
} | ||
declare const value: { | ||
<TValue extends undefined>(): ResultValue<TValue>; | ||
<TValue>(value: TValue): ResultValue<TValue>; | ||
<TValue extends undefined>(): ResultValue<TValue> & ResultBase<TValue, any>; | ||
<TValue>(value: TValue): ResultValue<TValue> & ResultBase<TValue, any>; | ||
}; | ||
declare type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>; | ||
declare type Result<TValue, TError extends Error> = ResultBase<TValue, TError>; | ||
export type { ResultValue, ResultError, Result }; | ||
export { value, error }; |
@@ -0,1 +1,8 @@ | ||
## [7.3.1](https://github.com/thenativeweb/defekt/compare/7.3.0...7.3.1) (2021-07-12) | ||
### Bug Fixes | ||
* Restructure type hierarchy so that types don't conflict internally. ([#330](https://github.com/thenativeweb/defekt/issues/330)) ([610302d](https://github.com/thenativeweb/defekt/commit/610302d31f2fe350393994fb84e8e6160657aca5)) | ||
# [7.3.0](https://github.com/thenativeweb/defekt/compare/7.2.3...7.3.0) (2021-07-03) | ||
@@ -2,0 +9,0 @@ |
interface ResultBase<TValue, TError extends Error> { | ||
hasError: () => this is ResultError<TError>; | ||
hasValue: () => this is ResultValue<TValue>; | ||
hasError: () => this is ResultError<TError> & ResultBase<any, TError>; | ||
hasValue: () => this is ResultValue<TValue> & ResultBase<TValue, any>; | ||
@@ -10,7 +10,7 @@ unwrapOrThrow: (errorTransformer?: (err: TError) => Error) => TValue; | ||
interface ResultError<TError extends Error> extends ResultBase<unknown, TError> { | ||
interface ResultError<TError extends Error> { | ||
error: TError; | ||
} | ||
const error = function <TError extends Error>(err: TError): ResultError<TError> { | ||
const error = function <TError extends Error>(err: TError): ResultError<TError> & ResultBase<any, TError> { | ||
return { | ||
@@ -40,3 +40,3 @@ hasError (): boolean { | ||
interface ResultValue<TValue> extends ResultBase<TValue, Error> { | ||
interface ResultValue<TValue> { | ||
value: TValue; | ||
@@ -46,5 +46,5 @@ } | ||
const value: { | ||
<TValue extends undefined>(): ResultValue<TValue>; | ||
<TValue>(value: TValue): ResultValue<TValue>; | ||
} = function <TValue>(val?: TValue): ResultValue<TValue | undefined> { | ||
<TValue extends undefined>(): ResultValue<TValue> & ResultBase<TValue, any>; | ||
<TValue>(value: TValue): ResultValue<TValue> & ResultBase<TValue, any>; | ||
} = function <TValue>(val?: TValue): ResultValue<TValue | undefined> & ResultBase<TValue | undefined, any> { | ||
return { | ||
@@ -70,3 +70,3 @@ hasError (): boolean { | ||
type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>; | ||
type Result<TValue, TError extends Error> = ResultBase<TValue, TError>; | ||
@@ -73,0 +73,0 @@ export type { |
{ | ||
"name": "defekt", | ||
"version": "7.3.0", | ||
"version": "7.3.1", | ||
"description": "defekt is custom errors made simple.", | ||
@@ -35,5 +35,5 @@ "contributors": [ | ||
"devDependencies": { | ||
"assertthat": "6.3.3", | ||
"assertthat": "6.3.6", | ||
"roboter": "11.7.7", | ||
"semantic-release-configuration": "2.0.4" | ||
"semantic-release-configuration": "2.0.5" | ||
}, | ||
@@ -40,0 +40,0 @@ "repository": { |
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
34284