Skip to content

Commit

Permalink
Cherry-pick PR #39950 into release-4.0 (#39951)
Browse files Browse the repository at this point in the history
Component commits:
6e5d75b Use isUncalledFunctionReference for aliases too
Fixes bogus deprecated notices on imports of functions with deprecated
overloads, but with some non-deprecated overloads.

Fixes microsoft/vscode#104238

e2eb319 Just check all declarations, don't call isUncalledFunction

Co-authored-by: Nathan Shively-Sanders <[email protected]>
  • Loading branch information
TypeScript Bot and sandersn authored Aug 7, 2020
1 parent 264d27e commit 3055018
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35323,9 +35323,7 @@ namespace ts {
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}

if (isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated
|| every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
if (isImportSpecifier(node) && every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string);
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/cases/fourslash/jsdocDeprecated_suggestion8.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///<reference path="fourslash.ts" />

// @Filename: first.ts
//// /** @deprecated */
//// export declare function tap<T>(next: null): void;
//// export declare function tap<T>(next: T): T;
// @Filename: second.ts
//// import { tap } from './first';
//// tap

goTo.file('second.ts')
verify.noErrors()
verify.getSuggestionDiagnostics([]);
11 changes: 11 additions & 0 deletions tests/cases/fourslash/jsdocDeprecated_suggestion9.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
///<reference path="fourslash.ts" />

// @Filename: first.ts
//// export class logger { }
// @Filename: second.ts
//// import { logger } from './first';
//// new logger()

goTo.file('second.ts')
verify.noErrors()
verify.getSuggestionDiagnostics([]);

0 comments on commit 3055018

Please sign in to comment.