haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
134 stars 9 forks source link

FirebaseFunctions missing static objects #42

Closed clarkjones closed 4 years ago

clarkjones commented 4 years ago

normally you can do something like

import * as functions from 'firebase-functions'

export const listener = functions.https.onRequest((req, res) => { ...})

We should be able to do the same thing using FirebaseFunctions.https.onRequest(...) though https does not exist in the extern.

A current workaround is to use FirebaseFunctions.runWith({}).https.onRequest(...)

haxiomic commented 4 years ago

Seems the static Https methods are there, but at a different path:

import firebase_functions.lib.providers.Https;

Https.onRequest(...);

It's like this because FirebaseFunctions and Http are converted to classes, and we cannot expose the Http class as a field of FirebaseFunctions

We could typedef Https into the firebase-functions module but I initially opted against this because it can make the resulting externs messy, with multiple ways to access the same class. But I might revisit aliasing this in the future

clarkjones commented 4 years ago

Ahh ok didn't realize that, I guess it would have to be extern interface for it to work. Thanks for the quick response though. I'll probably stick with the workaround I stated because Https.onRequest requires me to explicitly return null in the function body since the return type is ts.AnyOf2<Void, Promise<Void>>