Open
Description
- Operating System version: macOS 10.15.7
- Browser version: Brave latest
- Firebase SDK version: 9.6.10
- Firebase Product: analytics
Setup code:
import { initializeApp } from "firebase/app"
import { getAnalytics, logEvent } from "firebase/analytics"
const firebaseApp = initializeApp(firebaseConfig)
const analytics = getAnalytics(firebaseApp)
Working:
type CustomEventNamesOnly = "some_custom_event" | "some_other_custom_event"
logEvent<CustomEventNamesOnly>(analytics, eventName, eventParams)
Also working:
type ExpectedEventNamesOnly = "select_item" | "set_checkout_option"
logEvent(analytics, eventName as ExpectedEventNamesOnly, eventParams)
Not working:
type CustomAndStandardEventNames = "some_custom_event" | "select_item"
logEvent<CustomAndStandardEventNames>(analytics, eventName, eventParams)
In reality I'm using logEvent
inside of a function that I'm calling from multiple places in my app, and I want to pass something like CustomAndStandardEventNames
to logEvent
as the type for eventName
.
It currently returns an error because of this type narrowing to never
when the event name extends EventNameString
but I don't see a good reason for this.