@@ -7,15 +7,6 @@ export type JSONValue = JSONPrimitive | JSONObject | JSONArray
77export type JSONObject = { [ member : string ] : JSONValue }
88export type JSONArray = JSONValue [ ]
99
10- /**
11- * A JSON object that allows undefined key/values which will be completely removed during serialization.
12- */
13- export type JSONObjectLoose = {
14- [ member : string ] : JSONValueLoose | undefined
15- }
16-
17- export type JSONValueLoose = JSONPrimitive | JSONObjectLoose | JSONValueLoose [ ]
18-
1910export type Callback = ( ctx : Context ) => Promise < unknown > | unknown
2011
2112export type Integrations = {
@@ -109,8 +100,26 @@ interface AnalyticsContext {
109100 [ key : string ] : any
110101}
111102
112- export type Traits = JSONObjectLoose
113- export type EventProperties = JSONObjectLoose
103+ // "object" is not ideal, but with JSONObject, we ran into at least one bad edge case around index sig.
104+
105+ /**
106+ * An object literal representing traits
107+ * - identify: https://segment.com/docs/connections/spec/identify/#traits
108+ * - group: https://segment.com/docs/connections/spec/group/#traits
109+ * @example
110+ * { name: "john", age: 25 }
111+ */
112+ export type Traits = object & JSONObject // intersection adds an index signature
113+
114+ /**
115+ * An object literal representing Segment event properties
116+ * - track: https://segment.com/docs/connections/spec/track/#properties
117+ * - page: https://segment.com/docs/connections/spec/page/#properties
118+ * - screen: https://segment.com/docs/connections/spec/screen/#properties
119+ * @example
120+ * { artistID: 2435325, songID: 13532532 }
121+ */
122+ export type EventProperties = object & JSONObject // intersection adds an index signature
114123
115124export interface SegmentEvent {
116125 messageId ?: string
0 commit comments