@@ -2,7 +2,12 @@ import wildcard from "wildcard";
22import mergeWith from "./merge-with" ;
33import joinArrays from "./join-arrays" ;
44import unique from "./unique" ;
5- import { CustomizeRule , ICustomizeOptions , Key } from "./types" ;
5+ import {
6+ CustomizeRule ,
7+ CustomizeRuleString ,
8+ ICustomizeOptions ,
9+ Key ,
10+ } from "./types" ;
611import { isPlainObject , isUndefined } from "./utils" ;
712
813function merge < Configuration extends object > (
@@ -68,7 +73,9 @@ function mergeWithCustomize<Configuration extends object>(
6873 } ;
6974}
7075
71- function customizeArray ( rules : { [ s : string ] : CustomizeRule } ) {
76+ function customizeArray ( rules : {
77+ [ s : string ] : CustomizeRule | CustomizeRuleString ;
78+ } ) {
7279 return ( a : any , b : any , key : Key ) => {
7380 const matchedRule =
7481 Object . keys ( rules ) . find ( ( rule ) => wildcard ( rule , key ) ) || "" ;
@@ -87,12 +94,12 @@ function customizeArray(rules: { [s: string]: CustomizeRule }) {
8794 } ;
8895}
8996
90- type Rules = { [ s : string ] : CustomizeRule | Rules } ;
97+ type Rules = { [ s : string ] : CustomizeRule | CustomizeRuleString | Rules } ;
9198
9299function mergeWithRules ( rules : Rules ) {
93100 return mergeWithCustomize ( {
94101 customizeArray : ( a : any , b : any , key : Key ) => {
95- let currentRule : CustomizeRule | Rules = rules ;
102+ let currentRule : CustomizeRule | CustomizeRuleString | Rules = rules ;
96103
97104 key . split ( "." ) . forEach ( ( k ) => {
98105 if ( ! currentRule ) {
@@ -122,7 +129,7 @@ function mergeWithRule({
122129 a,
123130 b,
124131} : {
125- currentRule : CustomizeRule | Rules ;
132+ currentRule : CustomizeRule | CustomizeRuleString | Rules ;
126133 a : any ;
127134 b : any ;
128135} ) {
@@ -159,10 +166,10 @@ function mergeWithRule({
159166 return matches ;
160167 } ) ;
161168
162- if ( ! isPlainObject ( ao ) ) {
169+ if ( ! isPlainObject ( ao ) ) {
163170 return ao ;
164171 }
165-
172+
166173 Object . entries ( ao ) . forEach ( ( [ k , v ] ) => {
167174 const rule = currentRule ;
168175
@@ -278,7 +285,9 @@ function last(arr) {
278285 return arr [ arr . length - 1 ] ;
279286}
280287
281- function customizeObject ( rules : { [ s : string ] : CustomizeRule } ) {
288+ function customizeObject ( rules : {
289+ [ s : string ] : CustomizeRule | CustomizeRuleString ;
290+ } ) {
282291 return ( a : any , b : any , key : Key ) => {
283292 switch ( rules [ key ] ) {
284293 case CustomizeRule . Prepend :
0 commit comments