Skip to content

Commit 05be3b4

Browse files
authored
fix: show deprecated error for alias (#40961)
1 parent ad3ae36 commit 05be3b4

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22738,11 +22738,12 @@ namespace ts {
2273822738
}
2273922739

2274022740
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
22741-
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
22742-
22743-
if (declaration && getCombinedNodeFlags(declaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
22744-
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
22741+
const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
22742+
if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, sourceSymbol)) {
22743+
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
2274522744
}
22745+
22746+
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
2274622747
if (localOrExportSymbol.flags & SymbolFlags.Class) {
2274722748
// Due to the emit for class decorators, any reference to the class from inside of the class body
2274822749
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @filename: /foo.ts
4+
/////** @deprecated */
5+
////export function foo() {}
6+
7+
// @filename: /test.ts
8+
////import { [|foo|] } from "./foo";
9+
////[|foo|];
10+
11+
goTo.file("/test.ts");
12+
const [r0, r1] = test.ranges();
13+
14+
verify.getSuggestionDiagnostics([
15+
{
16+
"code": 6385,
17+
"message": "'foo' is deprecated",
18+
"reportsDeprecated": true,
19+
"range": r0
20+
},
21+
{
22+
"code": 6385,
23+
"message": "'foo' is deprecated",
24+
"reportsDeprecated": true,
25+
"range": r1
26+
}
27+
]);

0 commit comments

Comments
 (0)