How to use methods in the service layer that are not defined by interfaces when using typeScript in egg.js

since mysql, is not declared in the default Application interface in egg, it will cause an error to call directly according to the following method

 this.app.mysql.get()

to solve this problem, I used the following method

const app: any = this.app
app.mysql.get()

but if I write in this way, I think it will lose the meaning of writing typescript.

Mar.15,2021

you can write a type file yourself

import { Application } from "egg";

declare module "egg" {
    interface Application {
        mysql: any;
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1beff72-5491c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1beff72-5491c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?