fix(47256): show deprecated on index signatures (#47400)

This commit is contained in:
Oleksandr T
2022-02-16 03:13:04 +02:00
committed by GitHub
parent 39fe0318e0
commit a0bab5de5c
2 changed files with 34 additions and 0 deletions

View File

@@ -28587,6 +28587,9 @@ namespace ts {
if (compilerOptions.noPropertyAccessFromIndexSignature && isPropertyAccessExpression(node)) {
error(right, Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, unescapeLeadingUnderscores(right.escapedText));
}
if (indexInfo.declaration && getCombinedNodeFlags(indexInfo.declaration) & NodeFlags.Deprecated) {
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText as string);
}
}
else {
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {

View File

@@ -0,0 +1,31 @@
///<reference path="fourslash.ts" />
// @filename: foo.ts
////interface Foo {
//// /** @deprecated */
//// [k: string]: any;
//// /** @deprecated please use `.y` instead */
//// x: number;
//// y: number;
////}
////function f(foo: Foo) {
//// foo.[|x|];
//// foo.[|y|];
//// foo.[|z|];
////}
const ranges = test.ranges();
verify.getSuggestionDiagnostics([
{
"code": 6385,
"message": "'x' is deprecated.",
"reportsDeprecated": true,
"range": ranges[0]
},
{
"code": 6385,
"message": "'z' is deprecated.",
"reportsDeprecated": true,
"range": ranges[2]
},
]);