# Unexpected errors after switching to type script

**URL:** <https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293>\
**Category:** Help me!\
**Tags:** typescript\
**Created:** [November 12, 2020, 9:23am UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293 "2020-11-12T09:23:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bojan\_Antonijevic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/bojan_antonijevic/32/205_2.png) [@Bojan\_Antonijevic](https://community.forestadmin.com/u/Bojan_Antonijevic)\
**Post date:** [November 12, 2020, 9:23am UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/1 "2020-11-12T09:23:07Z")

</div>

This is a template you can use to report issues. You can also drag images, videos and include `Preformatted text`

## Expected behavior

We are upgraded to typescript recently with instructions:  
[https://docs.forestadmin.com/woodshop/how-tos/translate-your-app-into-typescript](https://docs.forestadmin.com/woodshop/how-tos/translate-your-app-into-typescript)  
dist folder is created properly, all files are compiled but we have:

1. SyntaxError in terminal and
2. Broken application.

## Actual behavior

 ![Screenshot 2020-11-12 at 10.11.50](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/e9be1c19dd66d6d027449cace455f638df0a9a9a.png) ![Screenshot 2020-11-12 at 10.11.41](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/acc2016a93ea179008b16154e9c4a1e3a4741784.png)

## Failure Logs

```javascript
account-features.js.map
Model creation error: SyntaxError: Unexpected token ':'
accounts.js.map
Model creation error: SyntaxError: Unexpected token ':'
agents.js.map
Model creation error: SyntaxError: Unexpected token ':'
features.js.map
Model creation error: SyntaxError: Unexpected token ':'
index.js.map
Model creation error: SyntaxError: Unexpected token ':'
interfaces
Model creation error: Error: Cannot find module '/Users/bojanantonijevic/Desktop/web-app/forest-admin/dist/models/interfaces'
Require stack:
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/node_modules/sequelize/lib/sequelize.js
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/node_modules/sequelize/index.js
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/dist/models/index.js
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/dist/middlewares/forestadmin.js
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/node_modules/require-all/index.js
- /Users/bojanantonijevic/Desktop/web-app/forest-admin/dist/app.js
subscribers.js.map
Model creation error: SyntaxError: Unexpected token ':'
Example app listening on port 3000!
Your admin panel is available here: https://app.forestadmin.com/projects

```

Logs are triggered from models/index.js:

```javascript
try {
      var model = sequelize['import'](path.join(__dirname, file));
      db[model.name] = model;
    } catch (error) {
      console.log(file);
      console.error('Model creation error: ' + error);
    }

```

## Context

Please provide any relevant information about your setup.

- Package Version:
- Express Version:
- Sequelize Version:
- Database Dialect:
- Database Version:
- Project Name:

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [November 12, 2020, 11:47am UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/2 "2020-11-12T11:47:40Z")

</div>

Hello @Bojan_Antonijevic,

I have been able to reproduce your exact issue.

Could you move the `interfaces` folder one step above and rewrite the imports in `routes` and `models` files.  
It should remove the:  
`Cannot find module '/Users/bojanantonijevic/Desktop/web-app/forest-admin/dist/models/interfaces'` error.

Also could you modify the file `models/index.js`:  
And replace line 27:

```javascript
.filter(function (file) {
    return file.indexOf('.') !== 0 && file !== 'index.js';
  })

```

by

```javascript
.filter(function (file) {
    return file.indexOf('.') !== 0 && file !== 'index.js' && file.indexOf('.js.map') === -1;
  })

```

It should remove the `SyntaxError: Unexpected token ':'` errors.

We will update the documentation for fixing this issue too.

Tell me if it helps 😃

---

<div class="post-metadata">

**Author:** ![Bojan\_Antonijevic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/bojan_antonijevic/32/205_2.png) [@Bojan\_Antonijevic](https://community.forestadmin.com/u/Bojan_Antonijevic)\
**Post date:** [November 12, 2020, 11:56am UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/3 "2020-11-12T11:56:48Z")

</div>

Thank you @Guillaume_Cisco,

Solutions from your reply fix the issues.

One more thing. Do you have any logs on your side regarding these errors from the console:

 ![Screenshot 2020-11-12 at 12.54.47](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/e8a18595d94ad02a10fd27b6d658721d867eb159.png)

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [November 12, 2020, 12:56pm UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/4 "2020-11-12T12:56:13Z")

</div>

You’re welcome @Bojan_Antonijevic.  
I’m glad it helped you.

Does your server correctly run on localhost with port `3310`?  
I can see from your previous logs it seems to run on `3000` .

Could you check your configuration, especially regarding ports.

Let me know if it helps 😉

---

<div class="post-metadata">

**Author:** ![Bojan\_Antonijevic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/bojan_antonijevic/32/205_2.png) [@Bojan\_Antonijevic](https://community.forestadmin.com/u/Bojan_Antonijevic)\
**Post date:** [November 12, 2020, 2:25pm UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/5 "2020-11-12T14:25:00Z")

</div>

Thank you once more 🙂. That solves our ERR\_CONNECTION\_REFUSED problems.

But we have one more.  
On any collection, we get 500 with the message:

```javascript
{"errors":[{"status":500,"detail":"connect ETIMEDOUT"}]}

```

Console errors:

 ![Screenshot 2020-11-12 at 15.23.13](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/38c1bf66b8146bdea0a6142f617a99c283b53905.png)

 ![Screenshot 2020-11-12 at 15.24.07](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/daa8d24398bfdc4cb0c8c9b0a1c1529e17956ba7.jpeg)

Do you have a clue?

---

<div class="post-metadata">

**Author:** ![Bojan\_Antonijevic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/bojan_antonijevic/32/205_2.png) [@Bojan\_Antonijevic](https://community.forestadmin.com/u/Bojan_Antonijevic)\
**Post date:** [November 12, 2020, 2:35pm UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/6 "2020-11-12T14:35:40Z")

</div>

No need, solved it. Thank you very much @Guillaume_Cisco 🙂

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [November 12, 2020, 2:43pm UTC](https://community.forestadmin.com/t/unexpected-errors-after-switching-to-type-script/1293/7 "2020-11-12T14:43:50Z")

</div>

You’re welcome 🙏

Wonderful everything is working great 🎉
