Skip to content

Object.freeze overloads force the type to be recognized as an array (by the order of overloads) #49149

Closed
@aghArdeshir

Description

@aghArdeshir

lib Update Request

Configuration Check

My compilation target is es5 and my lib is ["dom", "dom.iterable", "esnext"].
(Which I believe does not matter in this context as the definition of freeze is inside lib.es5.d.ts solely.)

Missing / Incorrect Definition

Object.freeze
image
It is defined in a way that in IDEs it is always supposed the input is an array.
image

Sample Code

Object.freeze<{someKey: 'someValue'}>({/* the problem is with autocomplete here (in IDEs) */});

Documentation Link

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


I believe the overload that forces arrays is defined in this PR:
https://github.com/microsoft/TypeScript/pull/12434/files

And I believe just removing it will suffice (and the user of Object.freeze needs to specify its an array in case its an array)


If it is confirmed, I would be happy to create the PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptExperimentation NeededSomeone needs to try this out to see what happensGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions