Skip to content

Commit df33dd5

Browse files
authored
fix(40441): show deprecated error for deprecated property in namespace (#40605)
1 parent 2428ade commit df33dd5

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13702,7 +13702,7 @@ namespace ts {
1370213702
if (propName !== undefined) {
1370313703
const prop = getPropertyOfType(objectType, propName);
1370413704
if (prop) {
13705-
if (reportDeprecated && accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
13705+
if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
1370613706
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
1370713707
errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string);
1370813708
}
@@ -25691,10 +25691,9 @@ namespace ts {
2569125691
propType = (compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
2569225692
}
2569325693
else {
25694-
if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
25694+
if (getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
2569525695
errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string);
2569625696
}
25697-
2569825697
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
2569925698
markPropertyAsReferenced(prop, node, left.kind === SyntaxKind.ThisKeyword);
2570025699
getNodeLinks(node).resolvedSymbol = prop;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @filename: foo.ts
4+
////export namespace foo {
5+
//// /** @deprecated */
6+
//// export const bar = 1;
7+
//// [|bar|];
8+
////}
9+
////foo.[|bar|];
10+
////foo[[|"bar"|]];
11+
12+
goTo.file('foo.ts');
13+
const ranges = test.ranges();
14+
verify.getSuggestionDiagnostics([
15+
{
16+
"code": 6385,
17+
"message": "'bar' is deprecated",
18+
"reportsDeprecated": true,
19+
"range": ranges[0]
20+
},
21+
{
22+
"code": 6385,
23+
"message": "'bar' is deprecated",
24+
"reportsDeprecated": true,
25+
"range": ranges[1]
26+
},
27+
{
28+
"code": 6385,
29+
"message": "'bar' is deprecated",
30+
"reportsDeprecated": true,
31+
"range": ranges[2]
32+
},
33+
]);

0 commit comments

Comments
 (0)