Skip to content

fix: show deprecated error for alias #40961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22730,11 +22730,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
Expand Down
27 changes: 27 additions & 0 deletions tests/cases/fourslash/jsdocDeprecated_suggestion11.ts
Original file line number Diff line number Diff line change
@@ -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
}
]);