Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IterableDiffers.extend is not AOT compatible #18554

Closed
trotyl opened this issue Aug 6, 2017 · 1 comment
Closed

IterableDiffers.extend is not AOT compatible #18554

trotyl opened this issue Aug 6, 2017 · 1 comment
Labels
area: core Issues related to the framework runtime core: differs freq2: medium P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Milestone

Comments

@trotyl
Copy link
Contributor

trotyl commented Aug 6, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

In IterableDiffers.extend API, it's using a static function call in providers list.

@Component({
  viewProviders: [
    IterableDiffers.extend([new ImmutableListDiffer()])
  ]
})

When using this, it would cause error in AOT compilation:

rror: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 187:19 in the original .ts file), resolving symbol IterableDiffers.extend in /Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/core/core.d.ts, resolving symbol AppComponent in /Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/src/app/app.component.ts, resolving symbol AppComponent in /Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/src/app/app.component.ts
    at positionalError (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:25104:35)
    at simplifyInContext (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24947:27)
    at StaticReflector.simplify (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24961:13)
    at StaticReflector.annotations (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24391:41)
    at NgModuleResolver.resolve (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:14733:70)
    at CompileMetadataResolver.getNgModuleMetadata (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:15386:60)
    at addNgModule (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24241:58)
    at /Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24252:14
    at Array.forEach (native)
    at _createNgModules (/Users/zjyu/Projects/Tmp/angular-cli/ng-tmp-f/node_modules/@angular/compiler/bundles/compiler.umd.js:24251:26)
Compilation failed

Expected behavior

There should be no error in AOT.

Possible solutions:

  1. Enhance the AOT compiler for allowing function call in Component.providers, since it's already (partially) supported in NgModule.imports;
  2. Refactor the IterableDiffers.extend API and making it return a new IterableDiffers instead of Provider, would be a breaking change in stable API.

Minimal reproduction of the problem with instructions

  • Clone this repo;
  • Install dependencies;
  • Run $(npm bin)/ngc -p src/tsconfig.app.json.

What is the motivation / use case for changing the behavior?

All Angular APIs should be AOT compatible.

Related to #11309 .

Also applies to KeyValueDiffers.

Environment


Angular version: 4.3.3 (Should be all since I don't think function calls in `providers` is ever supported)


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.2.1  
- Platform:  Mac OSX 10.12.6 

Others:

@vicb vicb added area: core Issues related to the framework runtime type: bug/fix labels Aug 7, 2017
@ngbot ngbot bot added this to the Backlog milestone Jan 23, 2018
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 26, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed severity3: broken labels Oct 1, 2020
mhevery added a commit to mhevery/angular that referenced this issue Dec 4, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR Close angular#25015
Issue Close #111309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.
mhevery added a commit to mhevery/angular that referenced this issue Dec 4, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR Close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR Close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  (This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.)
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  (This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.)
@mhevery mhevery closed this as completed in 5fc4508 Dec 7, 2020
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: differs freq2: medium P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
5 participants