Skip to content

Commit b0ca3fe

Browse files
authored
Add "how to use TypeScript" to README.md
refs netlify#76
1 parent 4454803 commit b0ca3fe

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,39 @@ The default webpack configuration uses `babel-loader` with a [few basic settings
8686

8787
However, if any `.babelrc` is found in the directory `netlify-lambda` is run from, it will be used instead of the default one. If you need to run different babel versions for your lambda and for your app, [check this issue](https://github.com/netlify/netlify-lambda/issues/34) to override your webpack babel-loader.
8888

89+
### How to use TypeScript
90+
8991
We added `.ts` and `.mjs` support recently - [check here for the PR and usage tips](https://github.com/netlify/netlify-lambda/pull/76).
9092

93+
1. Install `@babel/preset-typescript`
94+
95+
```bash
96+
npm install --save-dev @babel/preset-typescript
97+
```
98+
99+
2. Create custom `.babelrc`.
100+
101+
```diff
102+
{
103+
"presets": [
104+
"@babel/preset-typescript",
105+
[
106+
"@babel/preset-env",
107+
{
108+
"targets": {
109+
"node": "6.10.3"
110+
}
111+
}
112+
]
113+
],
114+
"plugins": [
115+
"@babel/plugin-proposal-class-properties",
116+
"@babel/plugin-transform-object-assign",
117+
"@babel/plugin-proposal-object-rest-spread"
118+
]
119+
}
120+
```
121+
91122
### --static option
92123

93124
If you need an escape hatch and are building your lambda in some way that is incompatible with our build process, you can skip the build with the `-s` or `--static` flag. [More info here](https://github.com/netlify/netlify-lambda/pull/62).

0 commit comments

Comments
 (0)