TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Intellisense should offer "constructor" property (Javascript)

Open jasonpolites opened this issue 7 months ago • 4 comments

Type: Feature Request

The intellisense (autocomplete) when used in the context of an ES6 class does not offer the constructor property when referenced from the this reference:

Image

Conversely, this property is available after a simple object has been created:

Image

VS Code version: Code 1.100.2 (848b80aeb52026648a8ff9f7c45a9b0a80641e2e, 2025-05-14T21:47:40.416Z) OS version: Windows_NT x64 10.0.19045 Modes: Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2

jasonpolites avatar May 27 '25 23:05 jasonpolites

This is intentional; many rarely-used things (specifically from Object) are not shown by default

RyanCavanaugh avatar Jun 16 '25 17:06 RyanCavanaugh

Ok, but unless I'm misreading the docs, there is literally only one property of Object that's not deprecated, and that's the constructor property

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#instance_properties

I don't know if I fully understand how "rarely-used" is determined, but personally I use this property a lot (referenced from the this pointer) in the context of inheritance.

What petition do I need to sign to have this removed from the "rarely-used" list 🙂

jasonpolites avatar Jun 16 '25 19:06 jasonpolites

hasOwnProperty, propertyIsEnumerable, isPrototypeOf are also things you can access on any Object.

RyanCavanaugh avatar Jun 16 '25 19:06 RyanCavanaugh

yes.. these are methods on object instances, but afaik constructor is the only instance-scoped "property" inherited by all objects.

Regardless, I think I'm suggesting the rubric for "rarely-used" could be made configurable, or at least published. Perhaps a way to override this behavior in jsconfig.json?

Maybe this is a performance optimization (?), but it's at the expense of correctness and just looks like a bug, particularly because auto complete does resolve constructor when accessed from an external reference/pointer.

jasonpolites avatar Jun 16 '25 20:06 jasonpolites

This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

typescript-bot avatar Jun 19 '25 01:06 typescript-bot