Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
22 lines
747 B
Plaintext
22 lines
747 B
Plaintext
"use strict"
|
|
|
|
/**
|
|
* Get the type of a node.
|
|
* If TypeScript isn't present, returns `null`.
|
|
*
|
|
* @param {import('estree').Node} node - A node
|
|
* @param {import('@typescript-eslint/parser').ParserServices} parserServices - A parserServices
|
|
* @returns {import('typescript').Type | null}
|
|
*/
|
|
module.exports = function getTypeOfNode(node, parserServices) {
|
|
const { esTreeNodeToTSNodeMap, program } = parserServices
|
|
if (program === null) {
|
|
return null
|
|
}
|
|
const tsNode = esTreeNodeToTSNodeMap.get(/** @type {any} */ (node))
|
|
const checker = program.getTypeChecker()
|
|
const nodeType = checker.getTypeAtLocation(tsNode)
|
|
const constrained = checker.getBaseConstraintOfType(nodeType)
|
|
return constrained ?? nodeType
|
|
}
|