mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
fix(40441): show deprecated error for deprecated property in namespace (#40605)
This commit is contained in:
@@ -13702,7 +13702,7 @@ namespace ts {
|
||||
if (propName !== undefined) {
|
||||
const prop = getPropertyOfType(objectType, propName);
|
||||
if (prop) {
|
||||
if (reportDeprecated && accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
|
||||
if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
|
||||
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
|
||||
errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string);
|
||||
}
|
||||
@@ -25691,10 +25691,9 @@ namespace ts {
|
||||
propType = (compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
|
||||
}
|
||||
else {
|
||||
if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
|
||||
if (getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
|
||||
errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string);
|
||||
}
|
||||
|
||||
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
|
||||
markPropertyAsReferenced(prop, node, left.kind === SyntaxKind.ThisKeyword);
|
||||
getNodeLinks(node).resolvedSymbol = prop;
|
||||
|
||||
33
tests/cases/fourslash/jsdocDeprecated_suggestion10.ts
Normal file
33
tests/cases/fourslash/jsdocDeprecated_suggestion10.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @filename: foo.ts
|
||||
////export namespace foo {
|
||||
//// /** @deprecated */
|
||||
//// export const bar = 1;
|
||||
//// [|bar|];
|
||||
////}
|
||||
////foo.[|bar|];
|
||||
////foo[[|"bar"|]];
|
||||
|
||||
goTo.file('foo.ts');
|
||||
const ranges = test.ranges();
|
||||
verify.getSuggestionDiagnostics([
|
||||
{
|
||||
"code": 6385,
|
||||
"message": "'bar' is deprecated",
|
||||
"reportsDeprecated": true,
|
||||
"range": ranges[0]
|
||||
},
|
||||
{
|
||||
"code": 6385,
|
||||
"message": "'bar' is deprecated",
|
||||
"reportsDeprecated": true,
|
||||
"range": ranges[1]
|
||||
},
|
||||
{
|
||||
"code": 6385,
|
||||
"message": "'bar' is deprecated",
|
||||
"reportsDeprecated": true,
|
||||
"range": ranges[2]
|
||||
},
|
||||
]);
|
||||
Reference in New Issue
Block a user