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

ZoneAwareError #14

Open
bunnywrote opened this issue Mar 9, 2017 · 2 comments
Open

ZoneAwareError #14

bunnywrote opened this issue Mar 9, 2017 · 2 comments

Comments

@bunnywrote
Copy link

I try to deserialize json like this:

deserialize(Event, json);

but get the follow error:

Error: Cannot resolve all parameters for 'Parser'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Parser' is decorated with Injectable

what i'm doing wrong?

@jf3096
Copy link
Owner

jf3096 commented Mar 9, 2017

could you send me your code or create a demo to reproduce the error?

@owen26
Copy link

owen26 commented Mar 10, 2017

I'm getting the same error.

class Book {
  title: string;

  getTitle(): string {
    return this.title;
  }
}
let b = deserialize(Book, {"title": "JS for Dummy"});
console.log('b', b);

I think this error not actually happens during deserialize code execution, but happens as soon as I access the website (angular-cli created project).

If I remove deserialize() statement, and all the @JsonProperty() decorator, this error is gone. But as soon as I put one decorator, the error comes back again even if there is no deserialize code at all.

Interestingly I tried several other similar libraries eg. json2typescript, class-transformer ,and I got the same error for them. I guess there is something wrong with my project itself, but I just can't figure out what it is.

Update
I just created a new project by using angular-cli, then imported only this package. It's the same error.

Error: Cannot resolve all parameters for 'Parser'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Parser' is decorated with Injectable.
    at NoAnnotationError.ZoneAwareError (http://localhost:4200/polyfills.bundle.js:3270:33)
    at NoAnnotationError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:24961:16)
    at new NoAnnotationError (http://localhost:4200/vendor.bundle.js:53210:16)
    at _dependenciesFor (http://localhost:4200/vendor.bundle.js:38187:15)
    at resolveReflectiveFactory (http://localhost:4200/vendor.bundle.js:38066:24)
    at resolveReflectiveProvider (http://localhost:4200/vendor.bundle.js:38091:139)
    at Array.map (native)
    at resolveReflectiveProviders (http://localhost:4200/vendor.bundle.js:38100:48)
    at Function.ReflectiveInjector.resolve (http://localhost:4200/vendor.bundle.js:70922:127)
    at Function.ReflectiveInjector.resolveAndCreate (http://localhost:4200/vendor.bundle.js:70955:79)
    at JitCompilerFactory.createCompiler (http://localhost:4200/vendor.bundle.js:65282:117)
    at PlatformRef_._bootstrapModuleWithZone (http://localhost:4200/vendor.bundle.js:36321:57)
    at PlatformRef_.bootstrapModule (http://localhost:4200/vendor.bundle.js:36308:21)
    at Object.322 (http://localhost:4200/main.bundle.js:33:124)
    at __webpack_require__ (http://localhost:4200/inline.bundle.js:53:30)

I think it might be some incompatibility issue with the new version of TypeScript. Really hope it can be sorted out.

Environment
@angular/cli: 1.0.0-beta.31
node: 6.9.1
os: darwin x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 2.4.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants