Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(50079): Show deprecation indicator also for JSX properties #50084

Merged
merged 1 commit into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/compiler/checker.ts
Expand Up @@ -28235,6 +28235,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 @@ -28263,6 +28264,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
},
]);