Dev Highlights

Доки по разработке

This project is maintained by teniryte

Type aliases vs Interfaces

Принципы

Пример

type Names1 = string[];
interface Names2 {
  [index: number]: string;
}

type Point = [number, number]; // интерфейс так не может
type LogFn = (message: string) => void;
interface LogInterface {
  (message: string): void;
}

interface ButtonProps {
  text: string;
  onClick: () => void;
}
interface ButtonProps {
  id: string;
} // declaration merging

Практика