Having such simple JS objects definitions:
...
const Post1 : TPost = {
title: "Post One",
body: "This is the Post One"
}
const Post2 : TPost = {
title: "Post Two",
body: "This is the Post Two"
}
...
and such TyprScript TPost type definition:
interface TPost {
title: string,
body: string
}
One can define a TPosts type like that
type TPosts = TPost[];
My question is how to do that - define TPosts as an array of TPost objects using the Interface syntax?
type TPosts = TPost[];is correct for makingTPostsan array ofTPost. So, I'm not sure I understand the question. Note that normally you don't declare a type for an array of something, the notationX[]is most often used. Not necessarily for technical reasons but it does make it easier to understand what the type is without needing to look it up, if you seeXsyou won't necessarily know it's an array ofX.