I have this array of Projects where stack has multiple strings
const projects: IProject[] = [
{name: '', description: '', stack: {'php', 'sql'}}
]
How will the interface be or what is the best approach?
interface IProject {
name: string
description: string
stack:
repo?: string
url?: string
}
I tried to declare another interface IStack[] but I don’t want another array of key value pairs as it increases my code
stack: [
{name: 'react'}, {name: 'graphql'}
]
2
Answers
If what you want is a fixed set of strings, you can use a union type:
Otherwise if you just want an array of random strings, you can use
stack: string[]
You can use in string array:
and the object is: