🧙 This post may be stale!
This post hasn't been updated in the past 6 months, some of the content could be a bit out of date!
I've found myself copy and pasting the same TypeScript snippet to add
type-safety for process.env.<X>
references in my various projects. I figured I
should just write a brief blog post to help myself with this in the future.
Use this snippet to override process.env
types:
Recipe:
- Create a
types.d.ts
file at the root of the project - Insert the above snippet
- Make sure to replace
KEY
with your env variables!
- Make sure to replace
- Add
./types.d.ts
to theincludes
array intsconfig.json