Open michaeljota opened 6 years ago
My concern with treating them "the same" in this context (if that means losing the TypeScript distinction between object
and Object
) is that with objects created by Object.create(null)
not passing instanceof Object
, object
comes across more as the generic "typeof(val) === 'object'" (not excepting null
, arrays or functions), whereas Object
suggests to me an object that is an instance of Object
.
My concern with this is that with objects created by
Object.create(null)
not passinginstanceof Object
,object
comes across more as the generic "typeof(val) === 'object'" (not exceptingnull
, arrays or functions), whereasObject
suggests to me an object that is an instance ofObject
.
Besides breaking this helpful distinction of benefit to JavaScript users familiar with the type differences, treating object
and Object
as fully the same could be more confusing to TypeScript users and those transitioning to it.
While I normally support greater JSDoc compatibility, in my personal opinion, you should avoid introducing more distinctions between the TypeScript JSDoc flavor and the TypeScript proper syntaxes. It's bad enough for compatibility that one can't go reliably in the other direction, e.g., so we one use JSDoc types like Object<string, string>
as a proper TypeScript type (yes, it is more verbose, but good for compatibility).
Of course if you just mean "Don't treat object.<string, number>
as "any", then that makes sense.
TypeScript Version: 2.7.0-dev.201xxxxx
Code
Expected behavior:
obj
should have a index signature as in #15105Actual behavior:
obj
is treated asany
Additional Info:
This was mentioned in the above issue, and it seems to be related to the way Typescript manage
Object
andobject
, but in JSDocs, they are treated similar.