# Is there a way to import TS vars file in serverless.yml?

**URL:** <https://forum.serverless.com/t/is-there-a-way-to-import-ts-vars-file-in-serverless-yml/3972>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [March 10, 2018, 10:27am UTC](https://forum.serverless.com/t/is-there-a-way-to-import-ts-vars-file-in-serverless-yml/3972 "2018-03-10T10:27:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Birowsky](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/birowsky/32/1163_2.png) [@Birowsky](https://forum.serverless.com/u/Birowsky)\
**Post date:** [March 10, 2018, 10:27am UTC](https://forum.serverless.com/t/is-there-a-way-to-import-ts-vars-file-in-serverless-yml/3972/1 "2018-03-10T10:27:04Z")

</div>

It’s a huge config object and I wanna reuse it within my typescript app. But serverless only supports js files, and I don’t wanna lose the config type information.

${file(./config.js)}

---

<div class="post-metadata">

**Author:** ![aneilbaboo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/aneilbaboo/32/1775_2.png) [@aneilbaboo](https://forum.serverless.com/u/aneilbaboo)\
**Post date:** [April 28, 2018, 8:56pm UTC](https://forum.serverless.com/t/is-there-a-way-to-import-ts-vars-file-in-serverless-yml/3972/2 "2018-04-28T20:56:17Z")

</div>

I did it by requiring typescript from a Javascript file like this:

```
module.exports = () => {
  require('ts-node').register({module: "commonjs"});
  require('tsconfig-paths').register();
  return require('./my-typescript.ts');
};

```

Update:

I discovered that this approach can cause problems when using serverless offline, as it invokes the expensive .register() method every time you invoke a lambda function. I found moving the require outside helps:

```
require('ts-node').register({module: "commonjs"});
require('tsconfig-paths').register();

module.exports = () => {
  return require('./my-typescript.ts');
};
```
