Skip to content

Commit af0f995

Browse files
authored
add example for typescript docs
1 parent d3edd6d commit af0f995

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ The default webpack configuration uses `babel-loader` with a [few basic settings
139139

140140
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.
141141

142-
### How to use TypeScript
142+
### Use with TypeScript
143143

144144
We added `.ts` and `.mjs` support recently - [check here for the PR and usage tips](https://github.com/netlify/netlify-lambda/pull/76).
145145

@@ -149,7 +149,9 @@ We added `.ts` and `.mjs` support recently - [check here for the PR and usage ti
149149
npm install --save-dev @babel/preset-typescript
150150
```
151151

152-
2. Create custom `.babelrc`.
152+
You may also want to add `typescript @types/node @types/aws-lambda`.
153+
154+
2. Create a custom `.babelrc` file:
153155

154156
```diff
155157
{
@@ -172,6 +174,8 @@ npm install --save-dev @babel/preset-typescript
172174
}
173175
```
174176

177+
3. (Optional) if you have `@types/aws-lambda` installed, your lambda functions can use the community typings for `Handler, Context, Callback`. See the typescript instructions in [create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/master/README.md#typescript) for an example.
178+
175179
### --static option
176180

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