In JS, `object` is treated as 'any'
See original GitHub issueTypeScript Version: 3.0.0-dev.20180711
Code
/** @typedef {object} T */
/** @type {T} */
const x = 0;
Expected behavior:
Error at x
: 0
is not an object.
Actual behavior:
No error.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Object.is() - JavaScript - MDN Web Docs
The Object.is() static method determines whether two values are the same value.
Read more >Why is the Object treated as an Array? - Stack Overflow
actually, arrays are objects, so it's arrays that are being treated like an object. Arrays can be thought of as objects that have...
Read more >Working with objects in JavaScript · WebPlatform Docs
In JavaScript, almost everything is an object. All primitive types except null and undefined are treated as objects. They can be assigned properties...
Read more >Objects - The Modern JavaScript Tutorial
We can immediately put some properties into {...} as “key: value” pairs: let user = { // an object ...
Read more >JavaScript Objects
In JavaScript, almost "everything" is an object. ... In JavaScript, all values, except primitive values, are objects. Primitive values are: strings ("John Doe"), ......
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
@sandersn I’ve personally been using:
Which is the inlined form of:
@ExE-Boss you can use the
type NonPrimitive = object
in one of your own d.ts files. Unfortunately, lots of existing JS code usesobject
to meanany
orunknown
, even projects like webpack that compile regularly with typescript.