microsoft / react-native-winrt

Windows Runtime projection for React Native for Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.d.ts generation should define WinRTPromise differently to make mocking easier

nichamp opened this issue · comments

Windows.Foundation.WinRTPromise was defined as (WinRTPromiseBase<TResult, TProgress> & Promise<TResult>) to best represent what is actually projected, but this makes it harder to write mocks. TypeScript requires async methods to return a plain Promise<T> so returning a Windows.Foundation.WinRTPromise wouldn't be possible. Mocks would have to return an explicit Promise object instead of using async methods, or would have to cheat with as. So I would recommend defining Windows.Foundation.WinRTPromise as Promise<TResult> | (WinRTPromiseBase<TResult, TProgress> & Promise<TResult>);