This message was deleted.
# community-help
s
This message was deleted.
d
for example, I make a change to the collection, how can I ensure my interfaces that use the search response are properly typed, such that during development the developer can be properly guided by the code completion tools.
right now I think the best way to do that is to build a companion script which, upon collection schema update, will generate the necessary types and save them somewhere statically
this would be similar to a migration tool for databases
here's what one of our devs did that works for us, can be extended using more types that we don't currently use:
Copy code
type TsType<T> =
    T extends "string" ? string :
    T extends "int64" ? number :
    T extends "bool" ? boolean : never

type TSData = {
    [K in FieldsType[number]['name']]: TsType<Extract<FieldsType[number], { name: K }>['type']>
}
this allows us to just read the
collection.json
and map it to an interface
one of our not-indexed fields is a json object with a pretty complex form, we store it just using string* and it's not indexed, but here's how we include that with the interface
Copy code
type _TSData= {
    [K in FieldsType[number]['name']]: TsType<Extract<FieldsType[number], { name: K }>['type']>
}
type TSData= Omit<_TSDATA, 'complexData'> & { complexData: ComplexDataInterface}