Files
SnowLuma/.pnpm-store/v11/files/f6/26472710d6f4ad30193c891193a4292c511224615b85c91c9086e017bd16493094d600747d419d32b3450c413e314d3c118e2445482e77cb146defd096594c
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

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;
}