# Announcing native TypeScript support for Netlify Functions

**URL:** <https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222>\
**Category:** Updates\
**Tags:** lambda-functions\
**Created:** [April 19, 2021, 5:28pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222 "2021-04-19T17:28:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardoboucas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/eduardoboucas/32/20463_2.png) [@eduardoboucas](https://answers.netlify.com/u/eduardoboucas)\
**Post date:** [April 19, 2021, 5:28pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/1 "2021-04-19T17:28:18Z")

</div>

Hi all! 👋

I wanted to share with you an exciting addition to our Functions offering: native support for TypeScript functions! 🎉

Up until now, using TypeScript with Netlify Functions involved an additional build step to compile the function code down to JavaScript. As of today, that’s no longer the case. You can simply add a `.ts` file to your functions directory and our build system handles the rest.

We’ve published [a blog post](https://www.netlify.com/blog/2021/04/19/announcing-native-typescript-support-for-netlify-functions/) with the announcement, as well as [updated documentation pages](https://docs.netlify.com/functions/build-with-typescript/) containing all the information you need to get started.

We’re very much looking forward to hearing your feedback and seeing what you build!

---

<div class="post-metadata">

**Author:** ![jonsully](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jonsully/32/15053_2.png) [@jonsully](https://answers.netlify.com/u/jonsully)\
**Post date:** [April 19, 2021, 6:35pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/2 "2021-04-19T18:35:53Z")

</div>

That’s awesome! Thanks team! Out of curiosity, is the backing Github repository meant to be public? Just wanted to check out the type definitions for the `event` and `context` objects since I know lots of folks ask for what the shapes of those objects are in various circumstances!

:netliheart:

–  
Jon

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [April 20, 2021, 3:45pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/4 "2021-04-20T15:45:19Z")

</div>

hey @jonsully - we’re looking into it. more details soon!

---

<div class="post-metadata">

**Author:** ![rstav](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rstav/32/13974_2.png) [@rstav](https://answers.netlify.com/u/rstav)\
**Post date:** [April 21, 2021, 5:17pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/5 "2021-04-21T17:17:03Z")

</div>

Thanks for asking about this!

The repo is now available publicly, and we’ll soon be adding a link to it from our docs.

Here’s a direct link for now: [GitHub - netlify/functions: JavaScript and TypeScript utilities for Netlify Functions.](https://github.com/netlify/functions)

---

<div class="post-metadata">

**Author:** ![jonsully](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jonsully/32/15053_2.png) [@jonsully](https://answers.netlify.com/u/jonsully)\
**Post date:** [April 21, 2021, 5:45pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/6 "2021-04-21T17:45:51Z")

</div>

Ahh fantastic 🕶 You guys rock! I think a lot of folks are going to appreciate the type definitions for event

> <https://github.com/netlify/functions/blob/main/src/function/event.ts>

and context

> <https://github.com/netlify/functions/blob/main/src/function/context.ts>

!! :netliheart:

–  
Jon

---

<div class="post-metadata">

**Author:** ![sidati](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sidati/32/23217_2.png) [@sidati](https://answers.netlify.com/u/sidati)\
**Post date:** [April 25, 2021, 5:19pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/7 "2021-04-25T17:19:59Z")

</div>

Hi @eduardoboucas,  
While everything seems to work seamlessly on production, TS functions are having issues working on netlify-dev, calling function url shows ☹

```
SyntaxError: Cannot use import statement outside a module
  ort { Handler } from '@netlify/functions';
  ^^^
  
  taxError: Cannot use import statement outside a module
  Object.compileFunction (node:vm:355:18)
  wrapSafe (node:internal/modules/cjs/loader:1022:15)
  Module._compile (node:internal/modules/cjs/loader:1056:27)
  Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
  Module.load (node:internal/modules/cjs/loader:972:32)
  Function.Module._load (node:internal/modules/cjs/loader:813:14)
  Module.require (node:internal/modules/cjs/loader:996:19)
  require (node:internal/modules/cjs/helpers:92:18)
  Object._executeSync ( ****** /node_modules/lambda-local/build/lambdalocal.js:277:26)
  Object.execute ( ****** /node_modules/lambda-local/build/lambdalocal.js:83:22)

```

My tsconfig.json

```
{
  "compilerOptions": {
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "noEmit": true,
    "target": "esnext",
    "module": "commonjs",
    "jsx": "react-jsx"
  }
}
```

---

<div class="post-metadata">

**Author:** ![eduardoboucas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/eduardoboucas/32/20463_2.png) [@eduardoboucas](https://answers.netlify.com/u/eduardoboucas)\
**Post date:** [April 26, 2021, 9:03am UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/8 "2021-04-26T09:03:34Z")

</div>

Hi @sidati! Sorry to hear that.

Can you confirm which version of the Netlify CLI you’re using? You can check this by running `netlify --version`.

---

<div class="post-metadata">

**Author:** ![sidati](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sidati/32/23217_2.png) [@sidati](https://answers.netlify.com/u/sidati)\
**Post date:** [April 26, 2021, 12:38pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/9 "2021-04-26T12:38:32Z")

</div>

Hi @eduardoboucas, this is my netlify-cli version  
`netlify-cli/3.21.10 darwin-x64 node-v15.14.0`

---

<div class="post-metadata">

**Author:** ![sidati](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sidati/32/23217_2.png) [@sidati](https://answers.netlify.com/u/sidati)\
**Post date:** [April 27, 2021, 2:59pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/10 "2021-04-27T14:59:35Z")

</div>

Hi @eduardoboucas, Any news?

---

<div class="post-metadata">

**Author:** ![eduardoboucas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/eduardoboucas/32/20463_2.png) [@eduardoboucas](https://answers.netlify.com/u/eduardoboucas)\
**Post date:** [April 27, 2021, 4:10pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/11 "2021-04-27T16:10:06Z")

</div>

Can you please try upgrading to version `3.22.0` and seeing if the issue still persists? If so, could you provide a repository with a reproduction case? I’m not able to reproduce this currently.

EDIT: Updated answer to reflect the newly-released version `3.22.0` of the CLI.

---

<div class="post-metadata">

**Author:** ![sidati](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sidati/32/23217_2.png) [@sidati](https://answers.netlify.com/u/sidati)\
**Post date:** [May 2, 2021, 11:55pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/12 "2021-05-02T23:55:09Z")

</div>

It seems removing `/node_modules + package-lock.json` and `npm install` fix this issue 💪  
Thanks for the help 🙂

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [May 3, 2021, 1:23pm UTC](https://answers.netlify.com/t/announcing-native-typescript-support-for-netlify-functions/36222/13 "2021-05-03T13:23:30Z")

</div>

Thanks for letting us know, @sidati! :netliconfetti:
