Skip to content

Commit 84bad5e

Browse files
committed
Use combined node flags
1 parent 2d09da6 commit 84bad5e

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13287,7 +13287,7 @@ namespace ts {
1328713287
function isUncalledFunctionReference(node: Node, symbol: Symbol) {
1328813288
return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method))
1328913289
|| !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent)
13290-
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated));
13290+
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated));
1329113291
}
1329213292

1329313293
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) {
@@ -13296,7 +13296,7 @@ namespace ts {
1329613296
if (propName !== undefined) {
1329713297
const prop = getPropertyOfType(objectType, propName);
1329813298
if (prop) {
13299-
if (accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
13299+
if (accessNode && prop.valueDeclaration && getCombinedNodeFlags(prop.valueDeclaration) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
1330013300
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
1330113301
errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string);
1330213302
}
@@ -22061,7 +22061,7 @@ namespace ts {
2206122061
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
2206222062
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
2206322063

22064-
if (declaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
22064+
if (declaration && getCombinedNodeFlags(declaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
2206522065
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
2206622066
}
2206722067
if (localOrExportSymbol.flags & SymbolFlags.Class) {
@@ -25038,7 +25038,7 @@ namespace ts {
2503825038
propType = indexInfo.type;
2503925039
}
2504025040
else {
25041-
if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
25041+
if (prop.valueDeclaration && getCombinedNodeFlags(prop.valueDeclaration) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
2504225042
errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string);
2504325043
}
2504425044

@@ -27492,7 +27492,7 @@ namespace ts {
2749227492
}
2749327493

2749427494
function checkDeprecatedSignature(signature: Signature, node: Node) {
27495-
if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
27495+
if (signature.declaration && getCombinedNodeFlags(signature.declaration) & NodeFlags.Deprecated) {
2749627496
errorOrSuggestion(/*isError*/ false, node, Diagnostics._0_is_deprecated, signatureToString(signature));
2749727497
}
2749827498
}
@@ -30883,7 +30883,7 @@ namespace ts {
3088330883
}
3088430884
const symbol = getNodeLinks(node).resolvedSymbol;
3088530885
if (symbol) {
30886-
if (every(symbol.declarations, d => !isTypeDeclaration(d) || !!(d.flags & NodeFlags.Deprecated))) {
30886+
if (every(symbol.declarations, d => !isTypeDeclaration(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
3088730887
const diagLocation = isTypeReferenceNode(node) && isQualifiedName(node.typeName) ? node.typeName.right : node;
3088830888
errorOrSuggestion(/* isError */ false, diagLocation, Diagnostics._0_is_deprecated, symbol.escapedName as string);
3088930889
}
@@ -35230,8 +35230,8 @@ namespace ts {
3523035230
}
3523135231

3523235232
if (isImportSpecifier(node) &&
35233-
(target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated
35234-
|| every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
35233+
(target.valueDeclaration && getCombinedNodeFlags(target.valueDeclaration) & NodeFlags.Deprecated
35234+
|| every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated)))) {
3523535235
errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string);
3523635236
}
3523735237
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// @Filename: a.tsx
2+
//// /** @deprecated */
3+
//// type Props = {}
4+
5+
//// /** @deprecated */
6+
//// const Component = (props: [|Props|]) => props && <div />;
7+
8+
//// <[|Component|] old="old" new="new" />
9+
10+
//// /** @deprecated */
11+
//// type Options = {}
12+
13+
//// /** @deprecated */
14+
//// const deprecatedFunction = (options: [|Options|]) => { options }
15+
16+
//// [|deprecatedFunction|]({});
17+
18+
goTo.file('a.tsx')
19+
const ranges = test.ranges();
20+
21+
verify.getSuggestionDiagnostics([
22+
{
23+
message: "'Props' is deprecated",
24+
code: 6385,
25+
range: ranges[0],
26+
reportsDeprecated: true,
27+
},
28+
{
29+
message: "'Component' is deprecated",
30+
code: 6385,
31+
range: ranges[1],
32+
reportsDeprecated: true
33+
},
34+
{
35+
message: "'Options' is deprecated",
36+
code: 6385,
37+
range: ranges[2],
38+
reportsDeprecated: true,
39+
},
40+
{
41+
message: "'deprecatedFunction' is deprecated",
42+
code: 6385,
43+
range: ranges[3],
44+
reportsDeprecated: true,
45+
}
46+
])

0 commit comments

Comments
 (0)