@@ -45,7 +45,7 @@ import { LOG } from './logger';
45
45
* Export interface for any Self-Describing JSON such as context or Self Describing events
46
46
* @typeParam T - The type of the data object within a SelfDescribingJson
47
47
*/
48
- export type SelfDescribingJson < T extends Record < keyof T , unknown > = Record < string , unknown > > = {
48
+ export type SelfDescribingJson < T extends { [ _ : string ] : unknown } = Record < string , unknown > > = {
49
49
/**
50
50
* The schema string
51
51
* @example 'iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0'
@@ -61,7 +61,7 @@ export type SelfDescribingJson<T extends Record<keyof T, unknown> = Record<strin
61
61
* Export interface for any Self-Describing JSON which has the data attribute as an array
62
62
* @typeParam T - The type of the data object within the SelfDescribingJson data array
63
63
*/
64
- export type SelfDescribingJsonArray < T extends Record < keyof T , unknown > = Record < string , unknown > > = {
64
+ export type SelfDescribingJsonArray < T extends { [ _ : string ] : unknown } = Record < string , unknown > > = {
65
65
/**
66
66
* The schema string
67
67
* @example 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1'
@@ -70,7 +70,7 @@ export type SelfDescribingJsonArray<T extends Record<keyof T, unknown> = Record<
70
70
/**
71
71
* The data array which should conform to the supplied schema
72
72
*/
73
- data : Array < T > ;
73
+ data : ( T extends SelfDescribingJson ? T : SelfDescribingJson < T > ) [ ] ;
74
74
} ;
75
75
76
76
/**
@@ -119,7 +119,7 @@ function getTimestamp(timestamp?: Timestamp | null): TimestampPayload {
119
119
}
120
120
121
121
/** Additional data points to set when tracking an event */
122
- export interface CommonEventProperties < T = Record < string , unknown > > {
122
+ export interface CommonEventProperties < T extends { [ _ : string ] : unknown } = Record < string , unknown > > {
123
123
/** Add context to an event by setting an Array of Self Describing JSON */
124
124
context ?: Array < SelfDescribingJson < T > > | null ;
125
125
/** Set the true timestamp or overwrite the device sent timestamp on an event */
0 commit comments