Why is it possible to use a class as a type in TypeScript, like word: Word
in the provided code snippet?
class Dict {
private words: Words = {};
// I am curious about this specific line
add(word: Word) {
if (!this.words[word.term]) {
this.words[word.term] = word.def;
}
}
}
class Word {
constructor(term: string, def: string) {}
}
I attempted to grasp this concept by referencing the official documentation, but unfortunately couldn't find any relevant information. https://www.typescriptlang.org/docs/handbook/2/everyday-types.html