11import type { NuxtConfigLayer } from "@nuxt/schema" ;
22import { defu } from "defu" ;
33
4- type GetModuleOptions <
5- T ,
6- K extends keyof NuxtConfigLayer [ "config" ] ,
7- > = [ T ] extends [ never ] ? NuxtConfigLayer [ "config" ] [ K ] : T ;
4+ type GetModuleOptions < T , K extends keyof NuxtConfigLayer [ "config" ] > = [ T ] extends [ never ]
5+ ? NuxtConfigLayer [ "config" ] [ K ]
6+ : T ;
87
98/**
109 * Get module options from a given Nuxt layer
@@ -21,21 +20,14 @@ type GetModuleOptions<
2120 */
2221export function getLayerModuleOptions <
2322 T = never ,
24- K extends keyof NuxtConfigLayer [ "config" ] = keyof NuxtConfigLayer [ "config" ] ,
25- > (
26- layer : NuxtConfigLayer ,
27- configKey : K ,
28- name : string ,
29- ) : GetModuleOptions < T , K > | undefined {
23+ K extends keyof NuxtConfigLayer [ "config" ] = keyof NuxtConfigLayer [ "config" ]
24+ > ( layer : NuxtConfigLayer , configKey : K , name : string ) : GetModuleOptions < T , K > | undefined {
3025 type Options = GetModuleOptions < T , K > ;
3126
3227 const matchInlineOptions = ( mod : any ) : mod is [ string , Options ] =>
3328 Array . isArray ( mod ) && typeof mod [ 0 ] === "string" && mod [ 0 ] === name ;
3429
35- const modules = ( layer . config . modules || [ ] ) as [
36- string ,
37- unknown | undefined ,
38- ] [ ] ;
30+ const modules = ( layer . config . modules || [ ] ) as [ string , unknown | undefined ] [ ] ;
3931 const inlineOptions = modules . find ( matchInlineOptions ) ?. [ 1 ] ;
4032 const keyOptions = layer . config [ configKey ] as Options | undefined ;
4133
0 commit comments