Skip to content

Commit

Permalink
fix(50079): show deprecated on JSX attributes (#50084)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Sep 1, 2022
1 parent 5df09a5 commit bcf9949
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compiler/checker.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions tests/cases/fourslash/jsdocDeprecated_suggestion18.ts
@@ -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.