@@ -148,7 +148,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
148148 while ( change ) {
149149 change = false ;
150150 for ( const [ id , chain ] of Object . entries ( overrideChains ) ) {
151- let next = chain [ chain . length - 1 ] ;
151+ let next = chain . at ( - 1 ) ! ;
152152 // If the next part of the chain is found in `overrideChains` we can merge them and remove the tail entry
153153 while ( overrideChains [ next . value ] ) {
154154 change = true ;
@@ -158,7 +158,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
158158 // In case of a cycle there will be a point where next equals the first element,
159159 // at which point it will delete itself.
160160 delete overrideChains [ next . value ] ;
161- next = chain [ chain . length - 1 ] ;
161+ next = chain . at ( - 1 ) ! ;
162162 }
163163 // Reset the loop since we are modifying the object we are iterating over
164164 if ( change ) {
@@ -175,7 +175,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
175175 * @param chains - The override chains to check.
176176 */
177177 protected validateChains ( chains : Resource [ ] [ ] ) : void {
178- const targets = chains . map ( ( chain ) : string => chain [ chain . length - 1 ] . value ) ;
178+ const targets = chains . map ( ( chain ) : string => chain . at ( - 1 ) ! . value ) ;
179179 for ( let i = 0 ; i < targets . length ; ++ i ) {
180180 const duplicateIdx = targets . findIndex ( ( target , idx ) : boolean => idx > i && target === targets [ i ] ) ;
181181 if ( duplicateIdx > 0 ) {
@@ -231,18 +231,18 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
231231 * @param chain - The chain to find the target of.
232232 */
233233 protected getChainTarget ( chain : Resource [ ] ) : Resource {
234- const target = chain [ chain . length - 1 ] ;
234+ const target = chain . at ( - 1 ) ! ;
235235 const types = uniqueTypes ( target , this . componentResources ) ;
236236 if ( ! types || types . length === 0 ) {
237- throw new ErrorResourcesContext ( `Missing type for override target ${ target . value } of Override ${ chain [ chain . length - 2 ] . value } ` , {
237+ throw new ErrorResourcesContext ( `Missing type for override target ${ target . value } of Override ${ chain . at ( - 2 ) ! . value } ` , {
238238 target,
239- override : chain [ chain . length - 2 ] ,
239+ override : chain . at ( - 2 ) ,
240240 } ) ;
241241 }
242242 if ( types . length > 1 ) {
243- throw new ErrorResourcesContext ( `Found multiple types for override target ${ target . value } of Override ${ chain [ chain . length - 2 ] . value } ` , {
243+ throw new ErrorResourcesContext ( `Found multiple types for override target ${ target . value } of Override ${ chain . at ( - 2 ) ! . value } ` , {
244244 target,
245- override : chain [ chain . length - 2 ] ,
245+ override : chain . at ( - 2 ) ,
246246 } ) ;
247247 }
248248 return target ;
0 commit comments