Created
October 25, 2024 03:11
-
-
Save fimars/0ce69c5c90b130a6dd9116936654e424 to your computer and use it in GitHub Desktop.
FIX `A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1170)`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PlanName = 'free' | 'starter' | 'growth' | 'plus' | |
type PlanDuration = 'monthly' | 'annually' | |
type BillingPlanEvent = `billing_${PlanName}_${PlanDuration}_click` | |
type GuidacneStep = 1 | 2 | 3 | |
type GuidanceEvent = `guidance_step${GuidacneStep}_next_click` | |
// A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1170) | |
// Fix? | |
export type UserEventPayload = { | |
home_tasks_click: {} | |
home_tasks_toggle: {} | |
billing_enter: {} | |
billing_leave: {} | |
apply_flash_sale: { | |
apply: 'on' | 'off' | |
} | |
billing_demo_click: {} | |
billing_customer_support_click: {} | |
} & { | |
// 1 | |
[K in BillingPlanEvent]: {} | |
} & { | |
// 2 | |
[K in GuidanceEvent]: {} | |
} | |
export type UserEventKey<E> = E extends keyof UserEventPayload ? E : never | |
export type UserEventProperties<E extends keyof UserEventPayload> = | |
UserEventPayload[E] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mapped type./