Issue 1:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Since I updated to Angular 2.4.1 and Angular-CLI beta.24 I get a compiler error which says that I should not use an inline arrow function for the useFactory but rather use an exported function.

That is no problem and I can exchange the code but why should I do that? I don't understand why this has changed because before version 2.4.1 it did not show me an error.

The funny thing about it is that the app works without any problem I am just getting this compiler error event tough the code works.

That is the way it wants me to do this but this to much unnecessery code, especially when I have more providers which use the useFactory.

export function translateFactory() {
return (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json')
}

@NgModule({
...,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: translateFactory,
deps: [Http]
})
})

There are already issues on a similar topic. #11262 as an example but none of them could answer my core question.

Expected behavior

I expect it to work like in earlier versions.

Where we could use it like in the example below.

Minimal reproduction of the problem with instructions

@NgModule({
...,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
deps: [Http]
})
})

results in this error

ERROR in 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 37:25 in the original .ts file), resolving symbol AppModule in /home/dev/project/frontend/src/app/app.module.ts

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

I mostly asking myself why this has changed.

There is nothing in the changelog which helps me.

So my questions are:

In version has this changed?

Why has this changed?

Do I really need to change every factory now or is this a bug and I can expect it to be fixed in a future version?

Please tell us about your environment:

Ubuntu 16.04

IntelliJ IDEA 2016.3.2

Angular 2.4.1

Angular-CLI beta.24

Browser:

negligible

Language:

TypeScript 2.0.10

Issue 2:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

If a provider specifies an inline function/arrow function for useFactory, the build fails with the error 'Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function.'

For instance, the following breaks:

providers: [
{
provide: AuthHttp,
deps: [Http, RequestOptions],
useFactory: function (http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig(), http, options);
}
}
]

but changing the notation to ES6 object method shorthand works:

providers: [
{
provide: AuthHttp,
deps: [Http, RequestOptions],
useFactory(http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig(), http, options);
}
}
]

This is completely bizarre IMHO since the semantics in the above examples are identical.

Expected behavior

Should work without issue

Minimal reproduction of the problem with instructions

Only occurs when compiling using AoT, not reproducible in a plunkr.

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

Please tell us about your environment:

Windows 7, NPM 3.10.8

Angular version: 2.4.0 (Was not an issue under Angular 2.2.x)

Angular-CLI version: 1.0.0-beta.24

Browser: N/A

Language: TypeScript 2.0.10

Node (for AoT issues): node --version =

6.9.1