@typescript-eslint/scope-manager
Advanced tools
Comparing version 4.0.2-alpha.10 to 4.0.2-alpha.11
@@ -18,2 +18,3 @@ import { TSESTree } from '@typescript-eslint/types'; | ||
protected TSIndexSignature(node: TSESTree.TSIndexSignature): void; | ||
protected TSInferType(node: TSESTree.TSInferType): void; | ||
protected TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void; | ||
@@ -20,0 +21,0 @@ protected TSMappedType(node: TSESTree.TSMappedType): void; |
@@ -21,2 +21,3 @@ "use strict"; | ||
const definition_1 = require("../definition"); | ||
const scope_1 = require("../scope"); | ||
class TypeVisitor extends Visitor_1.Visitor { | ||
@@ -102,2 +103,30 @@ constructor(referencer) { | ||
} | ||
TSInferType(node) { | ||
const typeParameter = node.typeParameter; | ||
let scope = __classPrivateFieldGet(this, _referencer).currentScope(); | ||
/* | ||
In cases where there is a sub-type scope created within a conditional type, then the generic should be defined in the | ||
conditional type's scope, not the child type scope. | ||
If we define it within the child type's scope then it won't be able to be referenced outside the child type | ||
*/ | ||
if (scope.type === scope_1.ScopeType.functionType || | ||
scope.type === scope_1.ScopeType.mappedType) { | ||
// search up the scope tree to figure out if we're in a nested type scope | ||
let currentScope = scope.upper; | ||
while (currentScope) { | ||
if (currentScope.type === scope_1.ScopeType.functionType || | ||
currentScope.type === scope_1.ScopeType.mappedType) { | ||
// ensure valid type parents only | ||
currentScope = currentScope.upper; | ||
continue; | ||
} | ||
if (currentScope.type === scope_1.ScopeType.conditionalType) { | ||
scope = currentScope; | ||
break; | ||
} | ||
break; | ||
} | ||
} | ||
scope.defineIdentifier(typeParameter.name, new definition_1.TypeDefinition(typeParameter.name, typeParameter)); | ||
} | ||
TSInterfaceDeclaration(node) { | ||
@@ -104,0 +133,0 @@ var _a, _b; |
{ | ||
"name": "@typescript-eslint/scope-manager", | ||
"version": "4.0.2-alpha.10+4d3ce5f6", | ||
"version": "4.0.2-alpha.11+95f6bf48", | ||
"description": "TypeScript scope analyser for ESLint", | ||
@@ -42,8 +42,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@typescript-eslint/types": "4.0.2-alpha.10+4d3ce5f6", | ||
"@typescript-eslint/visitor-keys": "4.0.2-alpha.10+4d3ce5f6" | ||
"@typescript-eslint/types": "4.0.2-alpha.11+95f6bf48", | ||
"@typescript-eslint/visitor-keys": "4.0.2-alpha.11+95f6bf48" | ||
}, | ||
"devDependencies": { | ||
"@types/glob": "*", | ||
"@typescript-eslint/typescript-estree": "4.0.2-alpha.10+4d3ce5f6", | ||
"@typescript-eslint/typescript-estree": "4.0.2-alpha.11+95f6bf48", | ||
"glob": "*", | ||
@@ -68,3 +68,3 @@ "jest-specific-snapshot": "*", | ||
}, | ||
"gitHead": "4d3ce5f696985389bf53a31d62766041c703c70c" | ||
"gitHead": "95f6bf4818cdec48a0583bf82f928c598af22736" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1036011
18739