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.

Question: difference between any and object without properties?

See original GitHub issue

In 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., which is why I’m asking here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

caseqcommented, May 19, 2021

@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).

TimvdLippecommented, May 18, 2021

Ah I see, I had missed the usage in js_protocol.pdl. I have asked internally for clarification on this.

Read more comments on GitHub >

github_iconTop 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 >

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 Post

No results found

github_iconTop Related Hashnode Post

No results found