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

Upgrade decorator syntax to Typescript 5.0 #208

Open
puchm opened this issue Feb 6, 2023 · 2 comments
Open

Upgrade decorator syntax to Typescript 5.0 #208

puchm opened this issue Feb 6, 2023 · 2 comments

Comments

@puchm
Copy link

puchm commented Feb 6, 2023

Typescript 5.0 (currently in beta) will introduce stable well-typed decorators. If experimentalDecorators is enabled, the current version will continue to work. If not, the new decorators require some changes to this library.

For example, this is the error that comes with @jsonObject:

Unable to resolve signature of class decorator when called as an expression.
  The runtime will invoke the decorator with 2 arguments, but the decorator expects 0-1.ts(1238)

Since the new version will replace the experimental syntax in the long term, this should be adjusted.

@leshniak
Copy link

Looks like the repo is abandoned again. Any alternatives?

@sumbricht
Copy link
Contributor

@leshniak, since you explicitly asked for an alternative since this seams abandoned... see below. Please note though that it also does not use TS5.0 decorators as (at least from what I'm seeing) the decorators don't have access to the constructor class, which is very unfortunate. Please correct me if I'm wrong about this.


For anyone blocked by TypedJSON issues: my own software heavily relied on TypedJSON and had to apply numerous hacks for issues in TypedJSON that are not getting fixed. I loved TypedJSON but unfortunately had to move on as there has not been a single fix in 4 years now.

Therefore I created the similarly powerful library json-class-serializer heavily inspired by TypedJSON, which addresses all my issues (and hopefully yours). It's pretty much a drop-in replacement if you don't rely on reflect-metadata, which I'm not supporting (as this was the cause of most of my issues). If you rely on reflect-metadata, just specify the constructors of properties other than string/number/boolean and then it most likely just works.

Please feel free to give it a try if you feel the urge to move away from TypedJSON but don't want to do any heavy re-engineering. And please don't hate on me for the advertisement here as I have contributed to TypedJSON as well and opened many still-open issues :-).

You can find my library at @sumbricht/json-class-serializer and gladly open issues there if you feel something's missing / not working correctly.

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