In order to avoid the following problem:
import { IPriceData, IVolumeData } from "../../../models/index";
import { connectToDatabase } from '../../../lib/mongodb';
You can add an alias to the tsconfig.json
file:
"baseUrl": ".",
"paths": {
"@models/*": ["models/*"],
"@lib/*": ["lib/*"]
}
So that the imports now look:
import { IPriceData, IVolumeData } from "@models/index";
import { connectToDatabase } from '@lib/mongodb';
References: