firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Update wrappedFunction return type can be promise #126

Closed KoreanThinker closed 3 months ago

KoreanThinker commented 2 years ago

Following changes

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 commented 2 years ago

Now I signed cla/google. Please rescan 🙏.