@@ -50,7 +50,7 @@ export type DataStoreOptions<TData extends DataStoreData> = Prettify<
5050 *
5151 * - ⚠️ Don't reuse the same engine instance for multiple DataStores, unless it explicitly supports it!
5252 */
53- engine : ( ( ) => DataStoreEngine < TData > ) | DataStoreEngine < TData > ;
53+ engine : ( ( ) => DataStoreEngine ) | DataStoreEngine ;
5454 /**
5555 * A dictionary of functions that can be used to migrate data from older versions to newer ones.
5656 * The keys of the dictionary should be the format version that the functions can migrate to, from the previous whole integer value.
@@ -111,8 +111,12 @@ export type DataStoreOptions<TData extends DataStoreData> = Prettify<
111111 )
112112> ;
113113
114- /** Generic type that represents the serializable data structure saved in a {@linkcode DataStore} instance. */
115- export type DataStoreData < TData extends SerializableVal = SerializableVal > = Record < string , SerializableVal | TData > ;
114+ /**
115+ * Generic type that represents the serializable data structure saved in a {@linkcode DataStore} instance.
116+ * - ⚠️ Uses `object` instead of an index signature so that interfaces without an explicit index signature can be used as `TData`.
117+ * Make sure to only use JSON-serializable types here, otherwise unexpected behavior may occur!
118+ */
119+ export type DataStoreData = object ;
116120
117121//#region class
118122
@@ -141,7 +145,7 @@ export class DataStore<TData extends DataStoreData> {
141145 public readonly decodeData : DataStoreOptions < TData > [ "decodeData" ] ;
142146 public readonly compressionFormat : Exclude < DataStoreOptions < TData > [ "compressionFormat" ] , undefined > = "deflate-raw" ;
143147 public readonly memoryCache : boolean = true ;
144- public readonly engine : DataStoreEngine < TData > ;
148+ public readonly engine : DataStoreEngine ;
145149 public options : DataStoreOptions < TData > ;
146150
147151 /**
@@ -284,7 +288,7 @@ export class DataStore<TData extends DataStoreData> {
284288 }
285289
286290 // deserialize the data if needed
287- let parsed = await this . engine . deserializeData ( storedData , isEncoded ) ;
291+ let parsed = await this . engine . deserializeData ( storedData , isEncoded ) as TData ;
288292
289293 // run migrations if needed
290294 if ( storedFmtVer < this . formatVersion && this . migrations )
@@ -444,7 +448,7 @@ export class DataStore<TData extends DataStoreData> {
444448 if ( data === undefined || isNaN ( fmtVer ) )
445449 return ;
446450
447- const parsed = await this . engine . deserializeData ( data , isEncoded ) ;
451+ const parsed = await this . engine . deserializeData ( data , isEncoded ) as TData ;
448452 await Promise . allSettled ( [
449453 this . engine . setValue ( `__ds-${ this . id } -dat` , await this . engine . serializeData ( parsed ) ) ,
450454 this . engine . setValue ( `__ds-${ this . id } -ver` , fmtVer ) ,
0 commit comments