Skip to content

Use combined node flags #39403

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 2 commits into from
Jul 15, 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
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13307,7 +13307,7 @@ namespace ts {
function isUncalledFunctionReference(node: Node, symbol: Symbol) {
return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method))
|| !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent)
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated));
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
}

function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags, reportDeprecated?: boolean) {
Expand Down Expand Up @@ -22092,7 +22092,7 @@ namespace ts {
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;

if (declaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
if (declaration && getCombinedNodeFlags(declaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
}
if (localOrExportSymbol.flags & SymbolFlags.Class) {
Expand Down
46 changes: 46 additions & 0 deletions tests/cases/fourslash/jsdocDeprecated_suggestion6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// @Filename: a.tsx
//// /** @deprecated */
//// type Props = {}

//// /** @deprecated */
//// const Component = (props: [|Props|]) => props && <div />;

//// <[|Component|] old="old" new="new" />

//// /** @deprecated */
//// type Options = {}

//// /** @deprecated */
//// const deprecatedFunction = (options: [|Options|]) => { options }

//// [|deprecatedFunction|]({});

goTo.file('a.tsx')
const ranges = test.ranges();

verify.getSuggestionDiagnostics([
{
message: "'Props' is deprecated",
code: 6385,
range: ranges[0],
reportsDeprecated: true,
},
{
message: "'Component' is deprecated",
code: 6385,
range: ranges[1],
reportsDeprecated: true
},
{
message: "'Options' is deprecated",
code: 6385,
range: ranges[2],
reportsDeprecated: true,
},
{
message: "'deprecatedFunction' is deprecated",
code: 6385,
range: ranges[3],
reportsDeprecated: true,
}
])