Question: difference between any and object without properties?
See original GitHub issueIn the protocol definitions, I have seen occurrences of both type: "any"
and type: "object"
without any properties
list.
What’s the difference? Is it that any
can be anything including primitives (effectively any JSON value) but object
is limited to only structures with properties (effectively only JSON objects)?
In that case, does an object
without properties list represent a type whose properties are unknown/dynamic?
In the typescript definitions, I noticed that most params of type object
without properties are represented with the Headers
interface, which is basically {[key: string]: string}
. This would confirm my guess here. However, some are still translated into TS’s any
(e.g. PausedEvent.data
), which is why I’m asking here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
typescript - 'any' vs 'Object' - Stack Overflow
This is probably the best source to learn the difference. The main point is that object is a type for everything that is...
Read more >Object.defineProperty() - JavaScript - MDN Web Docs
A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property...
Read more >Documentation - Object Types - TypeScript
Each property in an object type can specify a couple of things: the type, whether the property is optional, and whether the property...
Read more >Copying Objects in JavaScript | DigitalOcean
An object is said to be shallow copied when the source top-level properties are copied without any reference and there exist a source ......
Read more >Object methods, "this" - The Modern JavaScript Tutorial
A function that is a property of an object is called its method. So, here we've got a method sayHi of the object...
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 FreeTop 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
Top GitHub Comments
@joffrey-bion, you’re reading it right – “type”: “any” implies any type at all, including primitive types such as boolean/numer/string, while “type”: “object” implies a JSON object (i.e. a dictionary with string keys and values of “any” type).
Ah I see, I had missed the usage in
js_protocol.pdl
. I have asked internally for clarification on this.