# Typescript

![](/files/-LUH8jS72czF2NywXhRQ)

gstore-node supports Typescript. Make sure you have installed the Types definition file for @google-cloud/datastore first:

```bash
npm install --save @types/google-cloud__datastore
```

Once you have installed the types for google Datastore, you just need to create a custom `Type` for your schema and pass it to the Schema and Model instance.

Let see it with an example

```javascript
// user.schema.ts

import GstoreNode from 'gstore-node';

const gstore = GstoreNode();

type UserType = {
    userName: string;
    email: string;
    age?: number; // optional
    tags?: string[]; // optional
    birthday?: Date; // optional
}

// Pass it on Schema creation
const schema = new Schema<UserType>({
    userName: { type: String },
    email: { type: String },
    age: { type: Number, optional: true },
    tags: { type: Array, optional: true },
    birthday: { type: Date, optional: true }
});

// Pass it on Model creation
const User = gstore.model<UserType>('User', schema);
```

It you want to allow **other properties** apart from those declared (see `explicitOnly` option in the [Schema options](/gstore-node/v4.x/schema/schema-options.md)), this is how you would create your Model:

```javascript
type UserType = {
    userName: string;
    email: string;
    age?: number; // optional
    tags?: string[]; // optional
    birthday?: Date; // optional
} & {[propName: string]: any}; // Allow any other properties

// Schema with "explicitOnly" set to "false"
const schema = new Schema<UserType>({
    userName: { type: String },
    email: { type: String },
    age: { type: Number, optional: true },
    tags: { type: Array, optional: true },
    birthday: { type: Date, optional: true }
}, { explicitOnly: false }); // explicitOnly set to "false"

const User = gstore.model<UserType>('User', schema);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sebloix.gitbook.io/gstore-node/v4.x/typescript.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
