# Typecript and path aliases

**URL:** <https://community.homey.app/t/typecript-and-path-aliases/88575>\
**Category:** Developers\
**Created:** [September 1, 2023, 7:16pm UTC](https://community.homey.app/t/typecript-and-path-aliases/88575 "2023-09-01T19:16:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baylife](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/baylife/32/83372_2.png) [@Baylife](https://community.homey.app/u/Baylife)\
**Post date:** [September 1, 2023, 7:16pm UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/1 "2023-09-01T19:16:21Z")

</div>

Cant seem to get regular path aliases to work.  
I can get it to compile, but it throws exception runtime.  
Anybody got it working?

```auto
{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "outDir": ".homeybuild/",
    "baseUrl": "./",
    "paths": {
      "xxx": ["xxx/yyy/*"]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 2, 2023, 7:04am UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/2 "2023-09-02T07:04:47Z")

</div>

This is a TypeScript compiler issue: it doesn’t replace the aliases (`@xxx/module`) with the correct path.

See [this page](https://www.devxperiences.com/pzwp1/2021/11/21/how-to-solve-the-problem-with-typescript-unresolved-path-aliases-in-transpiled-js-files/) and also [this one](https://dev.to/larswaechter/path-aliases-with-typescript-in-nodejs-4353).

---

<div class="post-metadata">

**Author:** ![Baylife](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/baylife/32/83372_2.png) [@Baylife](https://community.homey.app/u/Baylife)\
**Post date:** [September 2, 2023, 4:18pm UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/3 "2023-09-02T16:18:04Z")

</div>

Cant get it to work with homey as forces the output folder .homeybuild which module-alias is not happy about.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 2, 2023, 4:47pm UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/4 "2023-09-02T16:47:06Z")

</div>

In that case, just don’t use path aliases 😉

---

<div class="post-metadata">

**Author:** ![Baylife](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/baylife/32/83372_2.png) [@Baylife](https://community.homey.app/u/Baylife)\
**Post date:** [September 3, 2023, 5:28am UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/5 "2023-09-03T05:28:39Z")

</div>

I guess you’re right, though it’s frustrating with undocumented “rules” in Homey and not being able to follow general best practice.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 3, 2023, 6:27am UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/6 "2023-09-03T06:27:32Z")

</div>

To be honest, I don’t think this is an (undocumented) rule, it’s the TypeScript compiler that’s causing the issue, and there are some modules that provide a workaround (that just doesn’t always work, but that’s not the fault of Athom/Homey).

Besides that, it’s probably possible to get it working for Homey, I just haven’t looked at it very closely.

---

<div class="post-metadata">

**Author:** ![Baylife](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/baylife/32/83372_2.png) [@Baylife](https://community.homey.app/u/Baylife)\
**Post date:** [September 3, 2023, 7:18am UTC](https://community.homey.app/t/typecript-and-path-aliases/88575/7 "2023-09-03T07:18:37Z")

</div>

No maybe not directly, but since changing the outDir or the compiler or even completely removing the build script has not effect, the options are some what limited.
