# Can't build agent-nodejs with TypeScript

**URL:** https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396
**Category:** Help me!
**Created:** [October 18, 2022, 6:42pm UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396 "2022-10-18T18:42:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![brunorzn](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@brunorzn](https://community.forestadmin.com/u/brunorzn)
#### Post date: [October 18, 2022, 6:42pm UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396/1 "2022-10-18T18:42:25Z")

</div>

Hi,

My name is Bruno, I’m the CTO of Offishall [[www.offishall.io](http://www.offishall.io) ]

I can’t build my server with agent-nodejs with TypeScript.  
I use express and SQL, no Mongoose or Sequelize.

I don’t use koa, but I had to install “@types/koa\_\_router”, why ?

I wrote a very simple express server to test everything. Just copying code from your example.  
I try to build it with tsc. Here is my tsconfig.json:

```javascript
{
  "compilerOptions": {
    "target": "es2019",
    "module": "commonjs",
    "outDir": "./dist",
    "baseUrl": ".",
    "strict": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "useUnknownInCatchVariables": false,
    "paths": {
      "~/*": ["src/*"],
    },
  }
}

```

Errors are:

```javascript
node_modules/@forestadmin/datasource-customizer/dist/decorators/validation/collection.d.ts:3:58 - error TS2537: Type '{ operator: "Equal" | "NotEqual" | "LessThan" | "GreaterThan" | "Like" | "ILike" | "NotContains" | "LongerThan" | "ShorterThan" | "IncludesAll" | "Today" | "Yesterday" | "PreviousMonth" | ... 25 more ... | "Past"; value?: unknown; }[] | undefined' has no matching index signature for type 'number'.

3 declare type ValidationRule = ColumnSchema['validation'][number];
                                                           ~~~~~~

node_modules/@forestadmin/datasource-sql/dist/introspection/types.d.ts:2:87 - error TS2537: Type '{}' has no matching index signature for type 'number'.

2 export declare type SequelizeIndex = Awaited<ReturnType<QueryInterface['showIndex']>>[number];
                                                                                        ~~~~~~

node_modules/@forestadmin/datasource-sql/dist/introspection/types.d.ts:5:113 - error TS2537: Type '{}' has no matching index signature for type 'number'.

5 export declare type SequelizeReference = Awaited<ReturnType<QueryInterface['getForeignKeyReferencesForTable']>>[number];

```

This looks very promising though. Thanks for the help !

Bruno

---

<div class="post-metadata">

### Author: ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)
#### Post date: [October 19, 2022, 7:24am UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396/2 "2022-10-19T07:24:50Z")

</div>

Hi @brunorzn, and welcome to our community 👋

> I can’t build my server with agent-nodejs with TypeScript.  
> I use express and SQL, no Mongoose or Sequelize.

Could you also share the name of the associated project?

> I don’t use koa, but I had to install “@types/koa\_\_router”, why ?

Did you get an error related to the requirement of `@types/koa__router`? If so, would you mind share the stacktrace?

We use Koa internally, but manually installing `@types/koa__router` shouldn’t be required in your project.

For your error, adding

```javascript
"skipLibCheck": true

```

to your typescript config should prevent this error, or you can simply call `tsc --skipLibCheck`.

As a side note (and if you don’t need express in your project), you can also run the agent as a standalone process, as shown in [this quick start documentation](https://docs.forestadmin.com/developer-guide-agents-nodejs/getting-started/quick-start).

Let me know if that helps 🙏

---

<div class="post-metadata">

### Author: ![brunorzn](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@brunorzn](https://community.forestadmin.com/u/brunorzn)
#### Post date: [October 19, 2022, 9:31am UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396/4 "2022-10-19T09:31:10Z")

</div>

Hi @anon39848301

Thank you for your quick answer !

TL;DR

Adding @types/koa\_\_router and skipLibCheck to true did the trick.

* * *

Here is the stack trace for the @types/koa\_\_router

```javascript
node_modules/@forestadmin/agent/dist/framework-mounter.d.ts:1:23 - error TS2688: Cannot find type definition file for 'koa__router'.

1 /// <reference types="koa__router" />
                        ~~~~~~~~~~~

node_modules/@forestadmin/agent/dist/framework-mounter.d.ts:3:20 - error TS7016: Could not find a declaration file for module '@koa/router'. '/Users/bruno/dev/offishall/server/node_modules/@koa/router/lib/router.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/koa__router` if it exists or add a new declaration (.d.ts) file containing `declare module '@koa/router';`

3 import Router from '@koa/router';
                     ~~~~~~~~~~~~~

```

I do want to use Express and Typescript so I can reuse a lot of things from our existing codebase which is what I was lacking a year ago or so. Dev experience seems to be a lot better now 🙂

I don’t really mind adding the koa types but it’s not very clean 🙂

I’ve added the _skipLikCheck_ for now and the build is okay.

Thank you!

---

<div class="post-metadata">

### Author: ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)
#### Post date: [October 19, 2022, 9:48am UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396/5 "2022-10-19T09:48:42Z")

</div>

> I do want to use Express and Typescript so I can reuse a lot of things from our existing codebase which is what I was lacking a year ago or so. Dev experience seems to be a lot better now 🙂

This was one of the main goal of this new agent (Along with a lot of new features) 😃

w’ll take a look to see if we are able to reproduce this issue with koa\_\_router on our end (Since it should definitely not be required) and we’ll let you know.

Thanks for your response 🙏

---

<div class="post-metadata">

### Author: ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)
#### Post date: [January 17, 2024, 2:00pm UTC](https://community.forestadmin.com/t/cant-build-agent-nodejs-with-typescript/5396/6 "2024-01-17T14:00:01Z")

</div>

Hey there,

It’s been a while but our team just released a fix to prevent this issue from happening again in the future.

Thanks for sharing this with us.

Kind regards,  
Morgan
