mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 00:55:32 -05:00
fix: show deprecated error for alias (#40961)
This commit is contained in:
@@ -22738,11 +22738,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
||||
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
|
||||
|
||||
if (declaration && getCombinedNodeFlags(declaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
|
||||
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
|
||||
const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
|
||||
if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, sourceSymbol)) {
|
||||
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
|
||||
}
|
||||
|
||||
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
|
||||
if (localOrExportSymbol.flags & SymbolFlags.Class) {
|
||||
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
||||
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
||||
|
||||
27
tests/cases/fourslash/jsdocDeprecated_suggestion11.ts
Normal file
27
tests/cases/fourslash/jsdocDeprecated_suggestion11.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /foo.ts
|
||||
/////** @deprecated */
|
||||
////export function foo() {}
|
||||
|
||||
// @filename: /test.ts
|
||||
////import { [|foo|] } from "./foo";
|
||||
////[|foo|];
|
||||
|
||||
goTo.file("/test.ts");
|
||||
const [r0, r1] = test.ranges();
|
||||
|
||||
verify.getSuggestionDiagnostics([
|
||||
{
|
||||
"code": 6385,
|
||||
"message": "'foo' is deprecated",
|
||||
"reportsDeprecated": true,
|
||||
"range": r0
|
||||
},
|
||||
{
|
||||
"code": 6385,
|
||||
"message": "'foo' is deprecated",
|
||||
"reportsDeprecated": true,
|
||||
"range": r1
|
||||
}
|
||||
]);
|
||||
Reference in New Issue
Block a user