UNPKG

react-scripts

Version:
41 lines (36 loc) 1.09 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var schema = exports.schema = []; exports.default = function (context) { var markTypeAsUsed = function markTypeAsUsed(node) { context.markVariableAsUsed(node.id.name); }; return { DeclareClass: markTypeAsUsed, DeclareFunction: markTypeAsUsed, DeclareModule: markTypeAsUsed, DeclareVariable: markTypeAsUsed, GenericTypeAnnotation: function GenericTypeAnnotation(node) { var typeId = void 0; var scope = void 0; var variable = void 0; if (node.id.type === 'Identifier') { typeId = node.id; } else if (node.id.type === 'QualifiedTypeIdentifier') { typeId = node.id; do { typeId = typeId.qualification; } while (typeId.qualification); } for (scope = context.getScope(); scope; scope = scope.upper) { variable = scope.set.get(typeId.name); if (variable && variable.defs.length) { context.markVariableAsUsed(typeId.name); break; } } } }; };