Skip to content

Commit bcf9949

Browse files
authoredSep 1, 2022
fix(50079): show deprecated on JSX attributes (#50084)
1 parent 5df09a5 commit bcf9949

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
 

‎src/compiler/checker.ts

+7
Original file line numberDiff line numberDiff line change
@@ -28375,6 +28375,7 @@ namespace ts {
2837528375
*/
2837628376
function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, checkMode: CheckMode | undefined) {
2837728377
const attributes = openingLikeElement.attributes;
28378+
const attributesType = getContextualType(attributes, ContextFlags.None);
2837828379
const allAttributesTable = strictNullChecks ? createSymbolTable() : undefined;
2837928380
let attributesTable = createSymbolTable();
2838028381
let spread: Type = emptyJsxObjectType;
@@ -28403,6 +28404,12 @@ namespace ts {
2840328404
if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
2840428405
explicitlySpecifyChildrenAttribute = true;
2840528406
}
28407+
if (attributesType) {
28408+
const prop = getPropertyOfType(attributesType, member.escapedName);
28409+
if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
28410+
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
28411+
}
28412+
}
2840628413
}
2840728414
else {
2840828415
Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @jsx: preserve
4+
// @filename: foo.tsx
5+
////interface Props {
6+
//// /** @deprecated */
7+
//// x: number;
8+
//// y: number;
9+
////}
10+
////function A(props: Props) {
11+
//// return <div>{props.y}</div>
12+
////}
13+
////function B() {
14+
//// return <A [|x|]={1} [|y|]={1} />
15+
////}
16+
17+
const [range] = test.ranges();
18+
verify.getSuggestionDiagnostics([
19+
{
20+
"code": 6385,
21+
"message": "'x' is deprecated.",
22+
"reportsDeprecated": true,
23+
"range": range
24+
},
25+
]);

0 commit comments

Comments
 (0)
Please sign in to comment.