Unexpected type hint required for Date member
See original GitHub issueIt 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:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.@timfish However, constraining the generic type to a base-class should work, if the possible sub-types are also specified through the knownTypes setting.