vector-im-hydrogen-web/doc/TS-MIGRATION.md
2021-12-01 16:05:16 +05:30

910 B

Typescript style guide

Use type rather than interface for named parameters and POJO return values.

type and interface can be used somewhat interchangeably, but let's use type to describe data and interface to describe (polymorphic) behaviour.

Good examples of data are option objects to have named parameters, and POJO (plain old javascript objects) without any methods, just fields.

Also see this playground

Use Record<string, any> to describe a type that accepts any Javascript object.

Prefer this over index signature, any or object.