I have encountered a problem with declaration files in my AdonisJS project. The IoC container in Adonis utilizes ES6 import loader hooks to resolve dependencies. For instance, when importing the User model, it would appear as follows:
import User from "@ioc:App/Models/User";
However, due to the use of the @ioc: prefix, WebStorm lacks information on typings. To address this issue, you can create a TypeScript definition file in the /contracts directory like so:
declare module "@ioc:App/Models/User" {
}
Despite this solution, the User model still lacks typing information.
My goal is to extend the base Model class, "@ioc:Adonis/Lucid/Model", for "@ioc:App/Models/Users" while having the flexibility to add additional properties or methods specific to that model class. I attempted the following approach but it did not yield the desired outcome:
declare module "@ioc:App/Models/User" {
import Model from "@ioc:Adonis/Lucid/Model";;
export default Model;
}
As a beginner in TypeScript, I apologize if this issue seems simple and I am overlooking something crucial.