How to display errors:
1. The types declared in global *.d.ts cannot be used globally and need to be imported.
2. Idea will display a red line under the namespace.
3. Compilation and packaging will report typescript Cannot find namespace '*****'
Fix the problem:
1. Idea will let you import the type declaration file you want to reference. This is very troublesome and needs to be introduced in many places. Although it can solve the problem.
2. Import should be used in the head of the global declaration file where you reported the error. Remove this import. If it cannot be removed, what should I do if I want to import it? For details, see: Importing other modules in global declarations . As shown below
declare namespace Express {
interface Request {
user: import("./user").User;
}
}