# Typescript

### Type Information

When using Typescript you can provide the type of the dataset rows using the diamond `<>` operator.

```javascript
import { Table } from 'voici.js'

interface IPerson {
  firstname: string;
  lastname: string;
  age: number;
}

const data = [
  { firstname: 'Homer', lastname: 'Simpson', age: 39 },
  { firstname: 'Marge', lastname: 'Simpson', age: 36 },
  { firstname: 'Bart', lastname: 'Simpson', age: 10 },
  { firstname: 'Lisa', lastname: 'Simpson', age: 8 },
  { firstname: 'Maggie', lastname: 'Simpson', age: 1 }
];

const table = new Table<IPerson>(data);
```

Here, `table.dataset` is of type `Person[]`.

{% hint style="info" %}
If you have no`interface`declared, you can still provide the type of your dataset by using `new Table<(typeof data)[number]>`.
{% endhint %}

### Config

When declaring a config variable you might have to set the according type.

```typescript
import { Table, Config } from 'voici.js'

const data = [
  { firstname: 'Marge', lastname: 'Simpson', age: 36 },
  { firstname: 'Homer', lastname: 'Simpson', age: 39 },
  { firstname: 'Peter', lastname: 'Griffin', age: 42 },
  { firstname: 'Lois', lastname: 'Griffin', age: 43 }
];

const config: Config = { // Set type 'Config'
  order: {
    columns: ['lastname'],
    directions: ['asc']
  }
};

const table = new Table(data, config);
```


---

# 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://voici.larswaechter.dev/examples/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.
