Skip to content

Commit

Permalink
fix narrowing on toStringType
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Oct 18, 2021
1 parent bc503a9 commit 460460a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utilityFunctions/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ export const unsafeCast = <T>(_value: unknown): asserts _value is T => {
/**
* converts the given `value` to a string, preserving its value at compiletime where possible
*/
export const toStringType = <T extends Stringable>(
value: T,
): T extends TemplateLiteralStringable ? ToString<T> : string => value.toString() as never
export const toStringType: {
<T extends TemplateLiteralStringable>(value: T): ToString<T>
<T extends Stringable>(value: T): string
} = (value: Stringable) => value.toString() as never

/**
* asserts that a value matches the given type
Expand Down

0 comments on commit 460460a

Please sign in to comment.