TypeScript's TypeChecker API has functions like getAnyType
and getUndefinedType
, but there appears to be no getUnknownType
. How do I get unknown
as a Type
to use for equality checks?
I've used typeToString
to convert Type
to unknown
for equality checks in other cases, but for this case I need the Type
version of unknown
and can't figure out any viable workarounds.
Looking at checker.ts, the unknown type:
...is not exposed. I would recommend opening a PR in TypeScript's repo to add it to
TypeChecker
, as I believe they would accept it given the other methods found on there.In the meantime, you can hackily get it by doing the following: