File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -161,19 +161,40 @@ export const loadConfig = (file: string, output: IOutput): ITSConfig => {
161161 output . debug ( 'loaded config (from file):' , config ) ;
162162 if ( ext ) {
163163 return {
164- ...( ext . startsWith ( '.' )
165- ? loadConfig (
166- join ( configDir , ext . endsWith ( '.json' ) ? ext : `${ ext } .json` ) ,
167- output
168- )
169- : loadConfig ( resolveTsConfigExtendsPath ( ext , file ) , output ) ) ,
164+ ...normalizeTsConfigExtendsOption ( ext , file ) . reduce < ITSConfig > (
165+ ( pre , ext ) => ( {
166+ ...pre ,
167+ ...loadConfig ( ext , output )
168+ } ) ,
169+ { }
170+ ) ,
170171 ...config
171172 } ;
172173 }
173174
174175 return config ;
175176} ;
176177
178+ /**
179+ * normalizeTsConfigExtendsOption normalizes tsconfig extends option to a directly loadable path array
180+ * @param { string|string[] } ext
181+ * @param { string } file
182+ * @returns {string[] }
183+ */
184+ export function normalizeTsConfigExtendsOption (
185+ ext : string | string [ ] ,
186+ file : string
187+ ) : string [ ] {
188+ if ( ! ext ) return [ ] ;
189+ const configDir = dirname ( file ) ;
190+ const normExts = ( Array . isArray ( ext ) ? ext : [ ext ] ) . map ( ( e ) =>
191+ e . startsWith ( '.' )
192+ ? join ( configDir , e . endsWith ( '.json' ) ? e : `${ e } .json` )
193+ : resolveTsConfigExtendsPath ( e , file )
194+ ) ;
195+ return normExts ;
196+ }
197+
177198/**
178199 * resolveTsConfigExtendsPath resolves the path to the config file that is being inherited.
179200 * @param {string } ext the value of the extends field in the loaded config file.
You can’t perform that action at this time.
0 commit comments