generated from codibre/boilerplate-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding error definition for getters
- Loading branch information
1 parent
58d249e
commit b8a65a7
Showing
4 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import { assertAndGet, assertAndGetProperty } from './asserts'; | ||
import { isNonNullish, isString } from './guards'; | ||
import { KeysOfType, Nullable, ObjectKeyType } from './types'; | ||
import { AssertError, KeysOfType, Nullable, ObjectKeyType } from './types'; | ||
|
||
export function assertAndGetNonNullish<T>(value: Nullable<T>): NonNullable<T> { | ||
return assertAndGet(value, isNonNullish); | ||
} | ||
export function getDefinedProperty<T extends object, K extends keyof T>( | ||
obj: T, | ||
prop: K, | ||
errorCallOrMessage?: AssertError, | ||
): NonNullable<T[K]> { | ||
return assertAndGetProperty(obj, prop, isNonNullish); | ||
return assertAndGetProperty(obj, prop, isNonNullish, errorCallOrMessage); | ||
} | ||
|
||
export function assertAndGetStringProperty< | ||
T extends object, | ||
K extends KeysOfType<T, Nullable<string>>, | ||
>(obj: T, prop: K): string; | ||
>(obj: T, prop: K, errorCallOrMessage?: AssertError): string; | ||
export function assertAndGetStringProperty<T extends object, K extends keyof T>( | ||
obj: T, | ||
prop: K, | ||
errorCallOrMessage?: AssertError, | ||
): string; | ||
export function assertAndGetStringProperty<K extends keyof ObjectKeyType>( | ||
obj: any, | ||
prop: K, | ||
errorCallOrMessage?: AssertError, | ||
): string { | ||
return assertAndGetProperty(obj, prop, isString); | ||
return assertAndGetProperty(obj, prop, isString, errorCallOrMessage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters