Next.js Discord

Discord Forum

Typed Env in Turborepo

Answered
Nile tilapia posted this in #help-forum
Open in Discord
Nile tilapiaOP
I created a Turborepo repo, use Next.js' typedEnv feature. Used workspace Typescript version and the .next/types/env.d.ts file got generated but intellisense still doesn't suggest env vars. A brand new repo created from create-next-app works fine, but not Turborepo.
Answered by Nile tilapia
SOLVED: changed from
  "include": [
    "**/*.ts",
    "**/*.tsx",
    "next-env.d.ts",
    "next.config.js",
    ".next/types/**/*.ts"
  ],

to
  "include": [
    "**/*.ts",
    "**/*.tsx",
    "next-env.d.ts",
    "next.config.js",
    ".next/types/**/*.ts",
    ".next/dev/types/**/*.ts" // added
  ],

in tsconfig.json
View full answer

1 Reply

Nile tilapiaOP
SOLVED: changed from
  "include": [
    "**/*.ts",
    "**/*.tsx",
    "next-env.d.ts",
    "next.config.js",
    ".next/types/**/*.ts"
  ],

to
  "include": [
    "**/*.ts",
    "**/*.tsx",
    "next-env.d.ts",
    "next.config.js",
    ".next/types/**/*.ts",
    ".next/dev/types/**/*.ts" // added
  ],

in tsconfig.json
Answer