question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LoadChildrenCallback Typescript Error when arrow function specifier async

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

Type '() => Promise<Type<any> | Routes | NgModuleFactory<any> | Observable<Type<any> | Routes> | typeof LoginRouting>' is not assignable to type 'LoadChildrenCallback'.
  Type 'Promise<Type<any> | Routes | NgModuleFactory<any> | Observable<Type<any> | Routes> | typeof LoginRouting>' is not assignable to type 'Type<any> | Routes | NgModuleFactory<any> | Observable<Type<any> | Routes> | Promise<Type<any> | Routes | NgModuleFactory<...>>'.     
    Type 'Promise<Type<any> | Routes | NgModuleFactory<any> | Observable<Type<any> | Routes> | typeof LoginRouting>' is not assignable to type 'Promise<Type<any> | Routes | NgModuleFactory<any>>'.
      Type 'Type<any> | Routes | NgModuleFactory<any> | Observable<Type<any> | Routes> | typeof LoginRouting' is not assignable to type 'Type<any> | Routes | NgModuleFactory<any>'.
        Type 'Observable<Type<any> | Routes>' is not assignable to type 'Type<any> | Routes | NgModuleFactory<any>'.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

loadChildren: async () => import('./path/to/module')
                    .then(mod => mod.NgModule)

Please provide the environment you discovered this bug in (run ng version)

AngularCli: 14.0.x

Anything else?

Worked fine till 14 version

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
mlc-mlapiscommented, Jul 4, 2022

@Delagen If using the async modifier, the shorter version also doesn’t show the error.

loadChildren: async () => (await import('./route-module/route-module.module')).RouteModuleModule
0reactions
angular-automatic-lock-bot[bot]commented, Aug 4, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LoadChildrenCallback - Angular
A function that is called to resolve a collection of lazy-loaded routes. Must be an arrow function of the following form: () =>...
Read more >
Syntax error for Typescript arrow functions with generics
In this example, I put <Lecture> in front of the arrow function - so there is no error in the implementation, but now...
Read more >
Deeply Understanding JavaScript Async and Await with ...
Using await in any other case is a syntax error. ... In the case of arrow function, async is put after the =...
Read more >
What is Arrow Functions and how to use ... - iTech Empires
First Let's see how we can declare function in javascript and then will see arrow function next. var test = function(message) { console.log(message);...
Read more >
ES6 arrow functions, syntax and lexical scoping
ES2015 (ES6) introduces a really nice feature that punches above its weight in terms of simplicity to integrate versus time saving and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found