Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
To type arrays, we use generics.
Suppose you want an array to only contain numbers.
This is how you type it:
const nums: Array<number> = [1, 2, 3]
You can now add numbers to the array, but if you add a string for example you’ll have an error:

We use generics often with useState in React:
type GitHubData = {
avatar_url: string
name: string
created_at: string
bio: string
}
function App() {
const [data, setData] = useState<GitHubData>()
}