question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected type hint required for Date member

See original GitHub issue

It seems from the tests that members of Date type should be automatically deserialized without type hint. However, it didn’t deserialize as Date but Object which turns out be something like

new Object('2016-07-29')

Without type hint: deserialize as object

@JsonObject
export class Team {
  @JsonMember
  public createdAt: Date;
}

let json = { createdAt: '2016-07-29' };
let str = JSON.stringify(json);
TypedJSON.parse(str, Team);

With type hint: deserialize as Date

@JsonObject
export class Team {
  @JsonMember({ type: Date })
  public createdAt: Date;
}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JohnWeiszcommented, Oct 17, 2016

I decided on removing the warning for now, as it is likely that upon encountering a TypeError during deserialization a user would first check their @JsonMember declaration.

1reaction
JohnWeiszcommented, Jan 31, 2017

@timfish However, constraining the generic type to a base-class should work, if the possible sub-types are also specified through the knownTypes setting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown variable for Python typehint - Stack Overflow
I have a wrapper function, what should I put as the return value if the variable to be returned is unknown ...
Read more >
PEP 484 – Type Hints - Python Enhancement Proposals
Acceptable type hints​​ Type hints may be built-in classes (including those defined in standard library or third-party extension modules), abstract base classes, ...
Read more >
Python Type Checking (Guide) - Real Python
In this tutorial, you'll learn about the following: Type annotations and type hints; Adding static types to code, both your code and the...
Read more >
Python's “type hints” are a bit of a disappointment to me
Honestly, I've recently written a few 300-500 line programs in Python using type hints and I'm never going back. And I'm not even...
Read more >
Type hinting in PyCharm - JetBrains
Any time you're applying type hints, PyCharm checks if the type is used correctly according to the supported PEPs. If there is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found