X
Xata2y ago
SferaDev

Inferring Types

Hey @marco If you can infer it instead of setting it yourself that's a better option. The type you're hovering is the most correct one. It's telling TypeScript that you have an array, of serialized drop owner records and you selected all base columns and expanded the columns of the drop link.
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
SferaDev
SferaDevOP2y ago
Depends on how you normally write the props of your component and where you want typescript to error out if things change (like your schema). Writing your own types in the component and passing a record down to the component is perfectly fine and if you change the schema, the types won't match when calling the component. If you decide to use our types and define the props with our type helpers it's also fine and if you change the schema instead of erroring out on component use it might error inside the component when you read or use the properties. Each solution has its own pros and cons and depends on how you define your architecture, both are fine and unless you "lie" TypeScript with the as keyword, they will be typesafe. The helpers you might want to use are: JSONData is a helper that transforms the records into a serialized-friendly version. It accepts one generic which is any response coming from the SDK. SelectedPick is a helper to select a subset of properties of a record, it can also expand nested links up to 2 recursive levels. It accepts two generics: the record type and the array of columns selected.
Want results from more Discord servers?
Add your server