Skip to content

Commit

Permalink
fix: share image & file return type
Browse files Browse the repository at this point in the history
  • Loading branch information
zce committed Nov 12, 2023
1 parent 875026c commit d4c0661
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ const outputStatic = async (ref: string, fromPath: string, isImage?: true): Prom
* @param path source file path
* @returns reference public url
*/
export const outputFile = async (ref: string | undefined, fromPath: string): Promise<string | undefined> => {
export const outputFile = async <T extends string | undefined>(ref: T, fromPath: string): Promise<T> => {
if (ref == null) return ref
return outputStatic(ref, fromPath) as Promise<string>
return outputStatic(ref, fromPath) as Promise<T>
}

/**
Expand All @@ -98,7 +98,7 @@ export const outputFile = async (ref: string | undefined, fromPath: string): Pro
* @param path source file path
* @returns reference public url or image object
*/
export const outputImage = async (ref: string | undefined, fromPath: string): Promise<Image | string | undefined> => {
export const outputImage = async <T extends string | undefined>(ref: T, fromPath: string): Promise<Image | T> => {
if (ref == null) return ref
return outputStatic(ref, fromPath, true)
return outputStatic(ref, fromPath, true) as Promise<Image | T>
}

0 comments on commit d4c0661

Please sign in to comment.