Reputation: 57223
tickList is (or should be) an Array of type number
fpsObject = {
maxSamples: 100,
tickIndex: 0,
tickSum: 0,
tickList: []
}
Can I enforce this type without creating an interface? Or must I create an interface to do this? I would rather avoid creating an interface if at all possible. I've got too many interface files already!
Upvotes: 0
Views: 587
Reputation: 164
You can use this way also:
const fpsObject = {
maxSamples: 100,
tickIndex: 0,
tickSum: 0,
tickList: Array<number>()
}
console.log(fpsObject)
Upvotes: 1
Reputation: 11047
You can use as to type it:
const fpsObject = {
maxSamples: 100,
tickIndex: 0,
tickSum: 0,
tickList: [] as number[]
}
Upvotes: 2