midwayjs / midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
https://www.midwayjs.org/
MIT License
7.4k stars 577 forks source link

typing目录下的plugin.d.ts缺少例如redis,mongoose等定义 #1056

Closed gogogo1024 closed 3 years ago

gogogo1024 commented 3 years ago

egg生成的 // This file is created by egg-ts-helper@1.25.8 // Do not modify this file!!!!!!!!!

import 'egg'; import 'egg-onerror'; import 'egg-session'; import 'egg-i18n'; import 'egg-watcher'; import 'egg-multipart'; import 'egg-security'; import 'egg-development'; import 'egg-logrotator'; import 'egg-schedule'; import 'egg-static'; import 'egg-jsonp'; import 'egg-view'; import 'egg-validate'; import 'egg-mongoose'; import 'egg-sequelize'; import 'egg-jwt'; import 'egg-redis'; import 'egg-passport'; import 'egg-passport-twitter'; import 'egg-passport-facebook'; import 'egg-passport-qq'; import 'egg-passport-weixin'; import 'egg-email'; import { EggPluginItem } from 'egg'; declare module 'egg' { interface EggPlugin { onerror?: EggPluginItem; session?: EggPluginItem; i18n?: EggPluginItem; watcher?: EggPluginItem; multipart?: EggPluginItem; security?: EggPluginItem; development?: EggPluginItem; logrotator?: EggPluginItem; schedule?: EggPluginItem; static?: EggPluginItem; jsonp?: EggPluginItem; view?: EggPluginItem; validate?: EggPluginItem; mongoose?: EggPluginItem; redis?: EggPluginItem; } }

midwayjs生成的 // This file is created by egg-ts-helper // Do not modify this file!!!!!!!!! import 'egg'; import '@midwayjs/web'; import 'egg-onerror'; import 'egg-session'; import 'egg-i18n'; import 'egg-watcher'; import 'egg-multipart'; import 'egg-security'; import 'egg-development'; import 'egg-logrotator'; import 'egg-schedule'; import 'egg-static'; import 'egg-jsonp'; import 'egg-view'; import 'midway-schedule'; import 'egg-cors'; import { EggPluginItem } from 'egg'; declare module 'egg' { interface EggPlugin { onerror?: EggPluginItem; session?: EggPluginItem; i18n?: EggPluginItem; watcher?: EggPluginItem; multipart?: EggPluginItem; security?: EggPluginItem; development?: EggPluginItem; logrotator?: EggPluginItem; schedule?: EggPluginItem; static?: EggPluginItem; jsonp?: EggPluginItem; view?: EggPluginItem; schedulePlus?: EggPluginItem; cors?: EggPluginItem; } } 感觉就是egg相关的插件会有自动注入到这个d.ts文件

czy88840616 commented 3 years ago

是的,这里只是列举了egg插件,并将其导入,如果egg插件里没有写定义,那也生成不了。

czy88840616 commented 3 years ago

egg-mongoose 是在哪引的?

gogogo1024 commented 3 years ago

egg-mongoose 是在哪引的?

自己在项目lib中包了一个层,然后在plugin中替换掉的。 我的意思是egg-redis这个插件会注入进去的。

czy88840616 commented 3 years ago

项目lib里库搜索不到,为了精简依赖,我们只会扫描项目,自定义框架,egg 这三层。 https://github.com/midwayjs/egg-ts-helper/blob/master/index.js

gogogo1024 commented 3 years ago

https://github.com/midwayjs/egg-ts-helper/blob/master/index.js

咋说呢,现在引入redis,还没有插件,所以目前midwayjs又没有好的redis插件。。。

czy88840616 commented 3 years ago

redis 的sdk已经很成熟了吧,这个做成插件没有什么复用的价值啊。比如我快速写了一个文档,https://www.yuque.com/midwayjs/midway_v2/redis

gogogo1024 commented 3 years ago

https://www.yuque.com/midwayjs/midway_v2/redis

是可以,先用着吧,之前自己也是引用ioredis,然后再添加了些代码支持bloom filter。看来确实是纯sdk,想怎么使用自己去包装下。