TypeScript Interfaces
TypeScript Interfaces
Overloads
Cheat Sheet
Common Syntax Optionally take properties from
version: number;
interface Expect {
/** In bytes */
}
Used to describe the shape of payloadSize: number;
interface Ruler {
You can call this object via () - ( functions get size(): numbe r
(): JSONResponse
bigint, symbol to exist, and all properties must be numbers const r: Ruler = ...
Arrays:
data: Response
string[] or Array<string>
}
Tuple:
U sed here
C
interface API all {
C
const api: API all<Artwork all> = C ...
}
Avoid
api data . // Artwork
Sets a constraint on the type
You can constrain what types are accepted into the generic ‘ ’
status property can be used
Class conformance
parameter via the extends keyword.
C
interface API all<Response extends { status: number }> {
You can ensure a class conforms to an interface via implements:
data: Response
}
class Account implements Syncable { ... }
C
const api: API all<Artwork all> = C ...
.
api data status.