DocumentT<T>: Document & T

A Document typed with a user-defined data type. Typescript users can cast instances of Document to DocumentT to access user-defined fields with type safety.

The example below creates a local type "User" that is applied to queries for documents in a hypothetical "Users" collection.

Type Parameters

 type User = {
color: string
}

const response = await client.query<DocumentT<User>>(fql`
Users.byId("101")
`);
const user = response.data;

const color = user.color;

The Document class cannot be generic because classes cannot extend generic type arguments.