Skip to content
Permalink
Browse files
fix(50079): show deprecated on JSX attributes (#50084)
  • Loading branch information
a-tarasyuk committed Sep 1, 2022
1 parent 5df09a5 commit bcf994996ea0ddd8ca7daadd6b5fbc712eb5ce6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
@@ -28375,6 +28375,7 @@ namespace ts {
*/
function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, checkMode: CheckMode | undefined) {
const attributes = openingLikeElement.attributes;
const attributesType = getContextualType(attributes, ContextFlags.None);
const allAttributesTable = strictNullChecks ? createSymbolTable() : undefined;
let attributesTable = createSymbolTable();
let spread: Type = emptyJsxObjectType;
@@ -28403,6 +28404,12 @@ namespace ts {
if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
explicitlySpecifyChildrenAttribute = true;
}
if (attributesType) {
const prop = getPropertyOfType(attributesType, member.escapedName);
if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
}
}
}
else {
Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute);
@@ -0,0 +1,25 @@
///<reference path="fourslash.ts" />

// @jsx: preserve
// @filename: foo.tsx
////interface Props {
//// /** @deprecated */
//// x: number;
//// y: number;
////}
////function A(props: Props) {
//// return <div>{props.y}</div>
////}
////function B() {
//// return <A [|x|]={1} [|y|]={1} />
////}

const [range] = test.ranges();
verify.getSuggestionDiagnostics([
{
"code": 6385,
"message": "'x' is deprecated.",
"reportsDeprecated": true,
"range": range
},
]);

0 comments on commit bcf9949

Please sign in to comment.