File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -538,6 +538,44 @@ const routes: Route[] = [
538538 "UserType2" ,
539539 ] ) ;
540540 } ) ;
541+
542+ it ( "should allow resolve callbacks using inject() in feature Route[] declarations (issue #1433)" , ( ) => {
543+ const project = new Project ( { useInMemoryFileSystem : true } ) ;
544+ const sourceFile = project . createSourceFile (
545+ "/tmp/people-routing.module.ts" ,
546+ `
547+ import { Route } from "@angular/router";
548+
549+ const routes: Route[] = [
550+ {
551+ path: "",
552+ component: "PersonListComponent",
553+ canActivate: ["AuthGuard"],
554+ resolve: {
555+ personListLink: () => inject(PersonListResolver).resolvePersonListLink()
556+ }
557+ }
558+ ];
559+ ` ,
560+ ) ;
561+
562+ routerParser . cleanFileSpreads ( sourceFile ) ;
563+ routerParser . cleanCallExpressions ( sourceFile ) ;
564+ routerParser . cleanFileDynamics ( sourceFile ) ;
565+
566+ const initializer = sourceFile
567+ . getVariableDeclarationOrThrow ( "routes" )
568+ . getInitializerOrThrow ( ) . compilerNode ;
569+ const generated = new CodeGenerator ( ) . generate ( initializer ) ;
570+ const cleaned = routerParser . cleanRawRoute ( generated ) ;
571+
572+ let parsed : any ;
573+ expect ( ( ) => {
574+ parsed = require ( "json5" ) . parse ( cleaned ) ;
575+ } ) . not . to . throw ( ) ;
576+
577+ expect ( parsed [ 0 ] . resolve . personListLink ) . to . equal ( "[Function]" ) ;
578+ } ) ;
541579 } ) ;
542580
543581 // ── cleanFileSpreads() — path alias resolution (issue #1545) ─────────────
You can’t perform that action at this time.
0 commit comments