Commit 2c25ae0f authored by nanahira's avatar nanahira

fix plugin types again

parent 4c5d536c
......@@ -38,7 +38,7 @@
"ws": "^8.2.3"
},
"peerDependencies": {
"koishi": "^4.0.0-rc.0"
"koishi": "^4.0.0-rc.1"
}
},
"node_modules/@babel/code-frame": {
......
......@@ -24,22 +24,32 @@ export interface ContextSelector {
export type KoishiPluginOptions<T extends Plugin> = boolean | Plugin.Config<T>;
export interface KoishiModulePlugin<T extends Plugin> extends ContextSelector {
plugin: T | string;
options?: boolean | KoishiPluginOptions<T> | any;
export interface KoishiModulePluginExact<T extends Plugin>
extends ContextSelector {
plugin: T;
options?: boolean | KoishiPluginOptions<T>;
}
export function PluginDef<T extends keyof Plugin>(
export interface KoishiModulePluginName extends ContextSelector {
plugin: string;
options?: any;
}
export type KoishiModulePlugin<T extends Plugin = any> =
| KoishiModulePluginExact<T>
| KoishiModulePluginName;
export function PluginDef(
name: string,
options?: any,
select?: Selection,
);
): KoishiModulePluginName;
export function PluginDef<T extends Plugin>(
plugin: T,
options?: KoishiModulePlugin<T>,
options?: KoishiPluginOptions<T>,
select?: Selection,
);
export function PluginDef<T extends keyof Plugin>(
): KoishiModulePluginExact<T>;
export function PluginDef<T extends Plugin>(
plugin: T,
options?: KoishiPluginOptions<T>,
select?: Selection,
......
import { App } from 'koishi';
import { DefinePlugin } from '../src/register';
import { UsePlugin } from '../src/decorators';
import { PluginDef } from '../src/def';
import PluginLru from '@koishijs/plugin-cache-lru';
import PluginOnebot from '@koishijs/plugin-adapter-onebot';
@DefinePlugin()
class MyPlugin {
@UsePlugin()
loadLru() {
return PluginDef(PluginLru);
}
@UsePlugin()
loadOnebot() {
return PluginDef(PluginOnebot, { bots: [] });
}
}
describe('Inner plugin', () => {
let app: App;
beforeEach(() => {
app = new App();
// app.plugin(PluginOnebot, { bots: [] });
});
it('should load inner plugin properly', () => {});
});
......@@ -94,8 +94,8 @@ describe('Apply and Connect in koishi-thirdeye', () => {
app.plugin(MyPlugin2);
await RunApplyTest(app);
});
/*it('should be applied and connected with non-immediate dependency', async () => {
it('should be applied and connected with non-immediate dependency', async () => {
app.plugin(MyPlugin3);
await RunApplyTest(app);
});*/
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment