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

After upgrading from 2.2.1 to 2.4.1 loadChildren: () => Module in routes does not work anymore. Before upgrade I was able to use this construction to delegate certain route to external module. I did not use lazy loading. I used loadChildren to separate application parts.

Error in console:

Uncaught TypeError: Cannot convert undefined or null to object

thrown in:

ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
var /** @type {?} */ parentCtor = Object.getPrototypeOf(typeOrFunc.prototype).constructor;
var /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
var /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
return parentAnnotations.concat(ownAnnotations);
};

On the second line. typeOrFunc is my () => Module. It does not have prototype property.

Expected behavior

No idea how it worked before, but it did. I was able to navigate between modules, no errors were thrown.

Minimal reproduction of the problem with instructions

I used this scheme in my previous submission about DI. The repo is the same:

https://github.com/peku33/angular2-dependency-injection-failure

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

I want to use loadChildren() to logically separate parts of my app. I'm not using "lazy loading".

Please tell us about your environment:

Node v7.2.0

Npm 3.10.9

@angular/ [everything] @2.4.1

webpack@1.14.0

Angular version: 2.0.X

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Same on Chrome and Firefox

Language: [all | TypeScript X.X | ES6/7 | ES5] Version 2.1.4, ES6

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

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 you add an object instance to your route definition, the app fails to load with the error Cannot convert undefined or null to object with the stack trace:

at Function.getPrototypeOf (<anonymous>)
at ReflectionCapabilities.annotations (http://localhost:4200/main.bundle.js:60005:50)
at Reflector.annotations (http://localhost:4200/main.bundle.js:60197:44)
at DirectiveResolver.isDirective (http://localhost:4200/main.bundle.js:18021:61)
at http://localhost:4200/main.bundle.js:19618:42
at Array.forEach (native)
at CompileMetadataResolver._getEntryComponentsFromProvider (http://localhost:4200/main.bundle.js:19617:30)
at http://localhost:4200/main.bundle.js:19590:83
at Array.forEach (native)
at CompileMetadataResolver._getProvidersMetadata (http://localhost:4200/main.bundle.js:19560:19)
at http://localhost:4200/main.bundle.js:19562:23
at Array.forEach (native)
at CompileMetadataResolver._getProvidersMetadata (http://localhost:4200/main.bundle.js:19560:19)
at http://localhost:4200/main.bundle.js:19198:63
at Array.forEach (native)

The error ist thrown because ReflectionCapabilities.annotations tries to access the prototype of the passed variable which in this case is an object instance so fails.

This worked in 2.2.4 but fails with 2.3.1. It fails for a webpack build, I haven't tried any other build tools.

Expected behavior

The user should be able to add arbitrary properties to route entries without causing compilation errors.

Minimal reproduction of the problem with instructions

Add an object instance to a route definition like:

import { SomeObject } from "./some-object.model";

const routes: any = [
{
path: '',
children: [],
data: {
otherProperty: new SomeObject(),
}
}
];

see https://github.com/marcuskrahl/angular-bug-route-with-object-instance for an example repository

Workaround

If the object instance creation is replaced with a function call, the example works without any problems (but of course the access of the data has to be changed).

...
data: {
otherProperty: () => new SomeObject(),
}
...

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

You should be able to add application dependant information to routing entries.

Please tell us about your environment:

angular-cli changed to 2.3.1 runtime on Windows 7.

Also does not work on custom webpack build without angular-cli.

Angular version: 2.3.1

Browser: [all]

Language: [TypeScript 2.0.10]

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