Use combined node flags (#39403)

This commit is contained in:
Wenlu Wang 2020-07-16 00:22:12 +08:00 committed by GitHub
parent 7b728754c0
commit fcd4fcb3d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 2 deletions

View File

@ -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) {
@ -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) {

View File

@ -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,
}
])