-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Compile Time check for json decorator #93
Comments
Here's an example for context @json
class Foo {
public bar: string = "this is ok"
public baz: i32 | null = 0
// ^ this is not okay
}
Threw "unreachable" at runtime!
at 0:30 ... This will fail miserably and throw something like "index out of range" or "unreachable" which are highly non-descriptive. Rather: @json
class Foo {
public bar: string = "this is ok"
public baz: i32 | null = 0
// ^ this is not okay
}
ERROR: Property Foo.baz in <./src/index.ts> does not implement a JSON-compatible type!
Either decorate it with the `@omit` decorator or fix it! Instead, we actually throw at COMPILE TIME to ensure that the user has fault tolerant code |
Yeah that's perfectly put @JairusSW . Thanks for attaching the example to make the issue much clear. |
Reopening this as there are a few bugs |
@anyon17, after taking a closer look, it seems like to properly implement this (and a few other things), I'm going to have to take multiple passes over the AST via the transform. I'm not sure if your familiar with transforms, but its a pretty big undertaking, so I'll pull some features out and release a non-feature-complete version that's stable. This means I'll add full type checking in a later release. |
hey @JairusSW thanks for letting me know this detail. Will wait for the feature to become stable and looking forward to use it. Thanks again for picking up the requested feature. |
Right now a class decorated with
@json
containing fields which might not have types whose declaration have@json
decorator panics at the runtime. Is there any way to have this check at compile time so that compiler can exactly point to the field which does not have@json
decorator in it's declaration.The text was updated successfully, but these errors were encountered: