Skip to content

Pull up and export lambdas in Annotations so that AoT Compiler can reference it. #13138

Closed

Description

@mhevery

Depends on:

In JIT mode this code works.

@NgModule({
  providers: [
    {provide: SomeSymbol, useFactor: (i) => i.get('someSymbol'), deps: ['$injector']}
  ]
})
export class MyModule {}

but in AoT it needs to be written like so:

export factoryForSomeSymbol = (i) => i.get('someSymbol');

@NgModule({
  providers: [
    {provide: SomeSymbol, useFactor: factoryForSomeSymbol, deps: ['$injector']}
  ]
})
export class MyModule {}

ngc should be smart enough together with tsickle to perform this operation automatically for the developer.

Activity

  1. mhevery commented on Nov 29, 2016

    @mhevery
    ContributorAuthor
  2. added
    featureLabel used to distinguish feature request from other issues
    on Dec 3, 2016
  3. shlomiassaf commented on Jan 26, 2017

    @shlomiassaf
    Contributor

    @mhevery @tbosch @chuckjaz

    Now that microsoft/TypeScript#13604 is in master, and will be in 2.2 this is really important for implementing the mixin pattern.

    A use case will be an ActiveRecord library like ngResource but with full type information.

  4. chuckjaz commented on Jan 26, 2017

    @chuckjaz
    Contributor

    @shlomiassaf I am uncertain how this issue is related to mixins and microsoft/TypeScript#13604. Can you go into more detail?

  5. shlomiassaf commented on Jan 26, 2017

    @shlomiassaf
    Contributor

    I misinterpreted the proposal, it wont help :/

    Mixins are functions which are not supported by the compiler, not tsickle, my bad.

    Anyway, this only effects a mixin if you want to create a provider for it, then AOT wants a value.

  6. added this to the Backlog milestone on Jan 23, 2018
  7. added
    area: compilerIssues related to `ngc`, Angular's template compiler
    and removed
    area: coreIssues related to the framework runtime
    on Mar 10, 2020
  8. JoostK commented on Mar 14, 2020

    @JoostK
    Member

    This has been implemented in b6c4af6 for Angular 5.

  9. angular-automatic-lock-bot commented on Apr 14, 2020

    @angular-automatic-lock-bot

    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.

  10. locked and limited conversation to collaborators on Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilerfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions