Files
memecoin-botV2/.pnpm-store/v10/files/f6/26472710d6f4ad30193c891193a4292c511224615b85c91c9086e017bd16493094d600747d419d32b3450c413e314d3c118e2445482e77cb146defd096594c

20 lines
821 B
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConstrainedTypeAtLocation = getConstrainedTypeAtLocation;
/**
* Resolves the given node's type. Will return the type's generic constraint, if it has one.
*
* Warning - if the type is generic and does _not_ have a constraint, the type will be
* returned as-is, rather than returning an `unknown` type. This can be checked
* for by checking for the type flag ts.TypeFlags.TypeParameter.
*
* @see https://github.com/typescript-eslint/typescript-eslint/issues/10438
*/
function getConstrainedTypeAtLocation(services, node) {
const nodeType = services.getTypeAtLocation(node);
const constrained = services.program
.getTypeChecker()
.getBaseConstraintOfType(nodeType);
return constrained ?? nodeType;
}