mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
fix(47256): show deprecated on index signatures (#47400)
This commit is contained in:
@@ -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) {
|
||||
|
||||
31
tests/cases/fourslash/jsdocDeprecated_suggestion17.ts
Normal file
31
tests/cases/fourslash/jsdocDeprecated_suggestion17.ts
Normal 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]
|
||||
},
|
||||
]);
|
||||
Reference in New Issue
Block a user