1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | var schema = exports.schema = [];
|
7 |
|
8 | exports.default = function (context) {
|
9 | var markTypeAsUsed = function markTypeAsUsed(node) {
|
10 | context.markVariableAsUsed(node.id.name);
|
11 | };
|
12 |
|
13 | return {
|
14 | DeclareClass: markTypeAsUsed,
|
15 | DeclareFunction: markTypeAsUsed,
|
16 | DeclareModule: markTypeAsUsed,
|
17 | DeclareVariable: markTypeAsUsed,
|
18 | GenericTypeAnnotation: function GenericTypeAnnotation(node) {
|
19 | var typeId = void 0;
|
20 | var scope = void 0;
|
21 | var variable = void 0;
|
22 |
|
23 | if (node.id.type === 'Identifier') {
|
24 | typeId = node.id;
|
25 | } else if (node.id.type === 'QualifiedTypeIdentifier') {
|
26 | typeId = node.id;
|
27 | do {
|
28 | typeId = typeId.qualification;
|
29 | } while (typeId.qualification);
|
30 | }
|
31 |
|
32 | for (scope = context.getScope(); scope; scope = scope.upper) {
|
33 | variable = scope.set.get(typeId.name);
|
34 | if (variable && variable.defs.length) {
|
35 | context.markVariableAsUsed(typeId.name);
|
36 | break;
|
37 | }
|
38 | }
|
39 | }
|
40 | };
|
41 | }; |
\ | No newline at end of file |