Users can benefit the autocomplete and type-safe environment variable experience.
What?
This PR added experimental.typedEnv that generates a .d.ts file on Dev Server.
It generates from the loaded env files, except production specific files like .env.production.local.
How?
When starting the dev server, we read off the env files and next config.
If we validate that there is experimental.typedEnv set as true in next config, we generate a env.d.ts file inside the distDir (.next by default).
If there is a change in the env files, we rewrite the env.d.ts file.
Why?
Users can benefit the autocomplete and type-safe environment variable experience.
What?
This PR added
experimental.typedEnv
that generates a.d.ts
file on Dev Server. It generates from the loaded env files, except production specific files like.env.production.local
.How?
When starting the dev server, we read off the env files and next config.
If we validate that there is
experimental.typedEnv
set as true in next config, we generate aenv.d.ts
file inside thedistDir
(.next
by default).If there is a change in the env files, we rewrite the
env.d.ts
file.Fixes NEXT-542