firebase-functions-test icon indicating copy to clipboard operation
firebase-functions-test copied to clipboard

Update wrappedFunction return type can be promise

Open KoreanThinker opened this issue 3 years ago • 1 comments
trafficstars

Following changes

  • add WrappedFunction & WrappedScheduledFunction "generic"
  • change WrappedFunction & WrappedScheduledFunction's return type "any | Promise<any>" to "T"

Problem

In the v0.3.3 wrap()() this function's return type will be any. so when I test promise function using by chai.should, Automatic completion doesn't work. image

Solution

Return type any | Promise<any> must be any. So I use generic to "Promiseable" https://github.com/firebase/firebase-functions-test/blob/c1dd82b84f5fe4126ca666577a04a7d72e96f2fc/src/main.ts#L96-L99 change to

export type WrappedFunction<T = any> = (
  data: any,
  options?: ContextOptions
) => T;

then I can use like that image image

KoreanThinker avatar Jan 14 '22 11:01 KoreanThinker

Now I signed cla/google. Please rescan 🙏.

KoreanThinker avatar Jan 14 '22 11:01 KoreanThinker