Getting TypeScript to work with Netlify Functions

Both netlify-lambda build and netlify-lambda serve don’t seem to be verifying the types of TypeScript code. I tried it with the example project sw-yx/create-react-app-lambda-typescript, and something as simple as let a: number = 'abc' doesn’t trigger any warnings. How can I add type checking?

Marcus Weiner suggested that I use netlify dev and define a task that runs typescript with the watch flag -w so it will run on every code change, but I don’t know where to put it so it will run with netlify dev.

You’ll want to run that task as part of your build command. You can add the build command to your netlify.toml file or explicitly set it as mentioned in our cli docs. Hope that helps.

Thanks for the help, but I still don’t know how to add the tsc command to get TypeScript to check the types and keep listening for changes when developing.

That’ll be up to you how you add tsc to your build pipeline.