I’m working on a Nuxt.js project with TypeScript and I’m encountering issues with VSCode not recognizing my type definitions automatically. I want to avoid explicitly importing types in every file. Here is my setup and the problem I’m facing:
Project Setup
I have the following tsconfig.json
configuration:
{
"extends": "./.nuxt/tsconfig.json",
"include": ["./types/**/*.d.ts"]
}
Problem
Currently, I have to manually import types in each file, like this:
import { IMongoCase } from "~/types";
I would like to configure my project so that VSCode automatically recognizes the types without needing to import them explicitly in every file.
Attempts to Solve
I’ve tried the following:
- Ensured that the
types
folder is correctly placed and that the.d.ts
files are properly defined. - Restarted VSCode and its TypeScript server.
- Verified that the
paths
andbaseUrl
options are set correctly intsconfig.json
.
Desired Outcome
I want to be able to use the types directly in my code without importing them, like so:
const caseExample: IMongoCase = { ... };
Additional Context
- VSCode Version: 1.89.1
- TypeScript Version: 5.4.5
- Nuxt.js Version: 3.11.2
Question
How can I configure my project so that VSCode recognizes the type definitions automatically, without requiring explicit imports in each file? What changes do I need to make to my tsconfig.json
or any other configuration to achieve this?