Skip to content

Commit a0bab5d

Browse files
authored
fix(47256): show deprecated on index signatures (microsoft#47400)
1 parent 39fe031 commit a0bab5d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28587,6 +28587,9 @@ namespace ts {
2858728587
if (compilerOptions.noPropertyAccessFromIndexSignature && isPropertyAccessExpression(node)) {
2858828588
error(right, Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, unescapeLeadingUnderscores(right.escapedText));
2858928589
}
28590+
if (indexInfo.declaration && getCombinedNodeFlags(indexInfo.declaration) & NodeFlags.Deprecated) {
28591+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText as string);
28592+
}
2859028593
}
2859128594
else {
2859228595
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @filename: foo.ts
4+
////interface Foo {
5+
//// /** @deprecated */
6+
//// [k: string]: any;
7+
//// /** @deprecated please use `.y` instead */
8+
//// x: number;
9+
//// y: number;
10+
////}
11+
////function f(foo: Foo) {
12+
//// foo.[|x|];
13+
//// foo.[|y|];
14+
//// foo.[|z|];
15+
////}
16+
17+
const ranges = test.ranges();
18+
verify.getSuggestionDiagnostics([
19+
{
20+
"code": 6385,
21+
"message": "'x' is deprecated.",
22+
"reportsDeprecated": true,
23+
"range": ranges[0]
24+
},
25+
{
26+
"code": 6385,
27+
"message": "'z' is deprecated.",
28+
"reportsDeprecated": true,
29+
"range": ranges[2]
30+
},
31+
]);

0 commit comments

Comments
 (0)