Skip to content

Commit 47add50

Browse files
mottox2stefan--
authored andcommitted
Add "how to use TypeScript" to README.md
refs netlify#76
1 parent 5a31117 commit 47add50

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
@@ -90,8 +90,39 @@ The default webpack configuration uses `babel-loader` with a [few basic settings
9090

9191
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.
9292

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

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

97128
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)