Add .getObjectType()
to the TypeChecker
#61517
Labels
Milestone
.getObjectType()
to the TypeChecker
#61517
π Search Terms
"getNonPrimitiveType", "getObjectType", "TypeChecker"
β Viability Checklist
β Suggestion
I would like to propose adding
.getObjectType()
method to theTypeChecker
. Similar to methods like.getAnyType()
or.getUndefinedType()
, the returned type of.getObjectType()
would be theType
of theobject
type.Alternative name:
.getNonPrimitiveType()
. Same as the variable is named:π Motivating Example
If I see it right
object
is the only intrinsic / built-in type that does not have a.get
method. Might be this is intentional and also might beobject
isnβt considered intrinsic.The motivation is to fill in a gap. If there is one.
Somewhat similar to: #59256
π» Use Cases
The project I am working on is using TypeScript programatically. The
object
type is used to validate user input. A user provides a type and the logic checks if that type is assignable to theobject
type. If not, a friendly message is printed that an object type was expected.As a workaround, I create a fake type. Obviously this cannot work with TypeScript 7 anymore.
The text was updated successfully, but these errors were encountered: