diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/tslint/lib/rules/deprecationRule.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/tslint/lib/rules/deprecationRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/deprecationRule.js | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/node_modules/tslint/lib/rules/deprecationRule.js b/node_modules/tslint/lib/rules/deprecationRule.js index ef6180125..bcd8a7da4 100644 --- a/node_modules/tslint/lib/rules/deprecationRule.js +++ b/node_modules/tslint/lib/rules/deprecationRule.js @@ -88,16 +88,17 @@ function isDeclaration(identifier) { case ts.SyntaxKind.GetAccessor: case ts.SyntaxKind.SetAccessor: case ts.SyntaxKind.EnumDeclaration: + case ts.SyntaxKind.ModuleDeclaration: return true; case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.TypeAliasDeclaration: case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.ModuleDeclaration: case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.PropertyAssignment: case ts.SyntaxKind.EnumMember: case ts.SyntaxKind.ImportEqualsDeclaration: return parent.name === identifier; + case ts.SyntaxKind.PropertyAssignment: + return parent.name === identifier && + !tsutils_1.isReassignmentTarget(identifier.parent.parent); case ts.SyntaxKind.BindingElement: // return true for `b` in `const {a: b} = obj"` return parent.name === identifier && @@ -112,7 +113,9 @@ function getCallExpresion(node) { node = parent; parent = node.parent; } - return tsutils_1.isTaggedTemplateExpression(parent) || tsutils_1.isCallExpression(parent) && parent.expression === node ? parent : undefined; + return tsutils_1.isTaggedTemplateExpression(parent) || (tsutils_1.isCallExpression(parent) || tsutils_1.isNewExpression(parent)) && parent.expression === node + ? parent + : undefined; } function getDeprecation(node, tc) { var callExpression = getCallExpresion(node); @@ -122,7 +125,18 @@ function getDeprecation(node, tc) { return result; } } - var symbol = tc.getSymbolAtLocation(node); + var symbol; + var parent = node.parent; + if (parent.kind === ts.SyntaxKind.BindingElement) { + symbol = tc.getTypeAtLocation(parent.parent).getProperty(node.text); + } + else if (tsutils_1.isPropertyAssignment(parent) && parent.name === node || + tsutils_1.isShorthandPropertyAssignment(parent) && parent.name === node && tsutils_1.isReassignmentTarget(node)) { + symbol = tc.getPropertySymbolOfDestructuringAssignment(node); + } + else { + symbol = tc.getSymbolAtLocation(node); + } if (symbol !== undefined && Lint.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) { symbol = tc.getAliasedSymbol(symbol); } @@ -184,15 +198,12 @@ function getDeprecationFromDeclarations(declarations) { return undefined; } function getDeprecationFromDeclaration(declaration) { - for (var _i = 0, _a = declaration.getChildren(); _i < _a.length; _i++) { - var child = _a[_i]; - if (!tsutils_1.isJsDoc(child)) { - break; - } - if (child.tags === undefined) { + for (var _i = 0, _a = tsutils_1.getJsDoc(declaration); _i < _a.length; _i++) { + var comment = _a[_i]; + if (comment.tags === undefined) { continue; } - for (var _b = 0, _c = child.tags; _b < _c.length; _b++) { + for (var _b = 0, _c = comment.tags; _b < _c.length; _b++) { var tag = _c[_b]; if (tag.tagName.text === "deprecated") { return tag.comment === undefined ? "" : tag.comment; |