Skip to content

Commit 7ad32c9

Browse files
committed
fix: show deprecated error for alias
1 parent 66c877f commit 7ad32c9

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22730,11 +22730,9 @@ namespace ts {
2273022730
}
2273122731

2273222732
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
22733-
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
22733+
checkDeprecatedIdentifier(node, localOrExportSymbol);
2273422734

22735-
if (declaration && getCombinedNodeFlags(declaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
22736-
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
22737-
}
22735+
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
2273822736
if (localOrExportSymbol.flags & SymbolFlags.Class) {
2273922737
// Due to the emit for class decorators, any reference to the class from inside of the class body
2274022738
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
@@ -28307,6 +28305,13 @@ namespace ts {
2830728305
return returnType;
2830828306
}
2830928307

28308+
function checkDeprecatedIdentifier(node: Identifier, symbol: Symbol) {
28309+
const sourceSymbol = symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol;
28310+
if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, sourceSymbol)) {
28311+
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
28312+
}
28313+
}
28314+
2831028315
function checkDeprecatedSignature(signature: Signature, node: CallLikeExpression) {
2831128316
if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
2831228317
const suggestionNode = getDeprecatedSuggestionNode(node);
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)