Skip to content

"Cannot convert undefined or null to object" when ng serve with fesm15 files #15325

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

Closed
IgorMinar opened this issue Mar 21, 2017 · 5 comments
Closed
Labels
area: core Issues related to the framework runtime type: bug/fix

Comments

@IgorMinar
Copy link
Contributor

IgorMinar commented Mar 21, 2017

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
Exception thrown in the browser (during metadata collection?) in JIT mode:

Unhandled Promise rejection: Cannot convert undefined or null to object ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at getParentCtor (reflection_capabilities.ts:324)
    at ReflectionCapabilities.parameters (reflection_capabilities.ts:115)
    at Reflector.parameters (reflector.ts:42)
    at CompileMetadataResolver._getDependenciesMetadata (metadata_resolver.js:794)
    at CompileMetadataResolver._getFactoryMetadata (metadata_resolver.js:729)
    at CompileMetadataResolver.getProviderMetadata (metadata_resolver.js:1001)
    at JitCompiler._compileModule (compiler.js:172)
    at createResult (compiler.js:116)
    at ZoneDelegate.invoke (zone.js:334)
    at Zone.run (zone.js:126)
    at zone.js:713
    at ZoneDelegate.invokeTask (zone.js:367)
    at Zone.runTask (zone.js:166)
    at drainMicroTaskQueue (zone.js:546) TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at getParentCtor (http://localhost:4200/vendor.bundle.js:2414:49)
    at ReflectionCapabilities.parameters (http://localhost:4200/vendor.bundle.js:2234:45)
    at Reflector.parameters (http://localhost:4200/vendor.bundle.js:2496:44)
    at CompileMetadataResolver._getDependenciesMetadata (http://localhost:4200/vendor.bundle.js:40117:73)
    at CompileMetadataResolver._getFactoryMetadata (http://localhost:4200/vendor.bundle.js:40056:51)
    at CompileMetadataResolver.getProviderMetadata (http://localhost:4200/vendor.bundle.js:40324:43)
    at JitCompiler._compileModule (http://localhost:4200/vendor.bundle.js:50248:77)
    at createResult (http://localhost:4200/vendor.bundle.js:50192:25)
    at ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2970:26)
    at Zone.run (http://localhost:4200/polyfills.bundle.js:2762:43)
    at http://localhost:4200/polyfills.bundle.js:3349:57
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:3003:31)
    at Zone.runTask (http://localhost:4200/polyfills.bundle.js:2802:47)
    at drainMicroTaskQueue (http://localhost:4200/polyfills.bundle.js:3182:35)

Expected behavior
No error

Minimal reproduction of the problem with instructions

  1. ng new --ng4 test-app
  2. edit vi node_modules/\@angular/cli//models/webpack-configs/common.js and mainFields: ["es2015", "module", "main"] to resolve: { ... } block
  3. ng serve
  4. open http://localhost:4200 and check error in console
  • Angular version:
    4.0.0-rc.5
@IgorMinar IgorMinar added area: core Issues related to the framework runtime type: bug/fix labels Mar 21, 2017
@tbosch
Copy link
Contributor

tbosch commented Mar 21, 2017

JIT is broken with ES2015 because JIT produces ES5 and therefore fails when using inheritance (see #14816).

However, we shouldn't throw this error.

@tbosch
Copy link
Contributor

tbosch commented Mar 21, 2017

This is because in native ES6, arrow functions don't have a prototype field, which fails our metadata collection. E.g. the following test is different between ES6 and transpiled ES5 code:

const x = () => null;
expect(x.prototype).toBeDefined()

But if this error would not throw, we would see the error described in #14816.

Closing in favor of the tracking bug #15127

@tbosch tbosch closed this as completed Mar 21, 2017
@jusefb
Copy link

jusefb commented Mar 27, 2017

I have just done a simple upgrade from Angular 2 to Angular 4 and can not use the app anymore due to this error. Can anyone suggest a workaround? Please ignore, I have found the offending module. It was down to ngrx/store-devtools. Once I have upgraded to the latest version of this problem the issue went away

@orizens
Copy link

orizens commented Apr 7, 2017

thanks @jusefb

@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 Sep 11, 2019
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 type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants