TypeScript Fundamentals: Interfaces & Aliases
by Kwiz
Qs
7
Difficulty
Junior
Plays
0
Record
n/a
Question Preview
What are the main benefits of using a type alias?
type Second = number;

let timeInSecond: number = 10;
let time: Second = 10;
Question Preview
Type aliases are limited to primitive values only
Question Preview
Types in TypeScript can be self-referential
type NumVal = 1 | 2 | 3 | NumVal[];
Question Preview
Interfaces can extend from other interfaces
Question Preview
Interfaces can extend from classes
Question Preview
Unlike type aliases, TypeScript interfaces are used to describe object & object sub-types (arrays, functions) only
Question Preview
We should use interfaces to describe primitive types