File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 1
1
/** @typedef {import('../types/main').MetaPlugin } MetaPlugin */
2
2
3
- /** @type {import('../types/main').AddPluginType } */
3
+ /**
4
+ * @template {Function} T
5
+ * @param {import('../types/main').AddPluginOptions<T> } metaPluginAndOptions
6
+ */
4
7
export function addPlugin ( metaPluginAndOptions ) {
5
8
const {
6
9
name,
Original file line number Diff line number Diff line change @@ -3,20 +3,22 @@ type AnyFn = (...args: any[]) => any;
3
3
export interface MetaPlugin < F = AnyFn > {
4
4
name : string ;
5
5
plugin : F extends ( options ?: infer O ) => P ? F : any ;
6
- options ?: F extends ( options : infer O ) => P ? O : any ;
6
+ options ?: /* prettier-ignore */ (
7
+ F extends ( eleventyConfig : any , options ?: infer O ) => void ? O
8
+ : F extends ( options : infer O ) => P ? O
9
+ : any
10
+ ) ;
7
11
}
8
12
9
13
export interface MetaPluginWrapable extends MetaPlugin {
10
14
__noWrap ?: boolean ;
11
15
}
12
16
13
- interface AddPluginOptions {
17
+ export type AddPluginOptions < T > = MetaPlugin < T > & {
14
18
how ?: 'after' | 'before' | 'fixed' ;
15
19
location ?: 'top' | 'bottom' | string ;
16
- }
20
+ } ;
17
21
18
22
type AddPluginFn = ( plugins : MetaPlugin [ ] ) => MetaPlugin [ ] ;
19
23
20
- export type AddPluginType = < F > (
21
- metaPluginAndOptions : MetaPlugin < F > & AddPluginOptions ,
22
- ) => AddPluginFn ;
24
+ export type AddPluginType = < F > ( metaPluginAndOptions : AddPluginOptions < F > ) => AddPluginFn ;
You can’t perform that action at this time.
0 commit comments