mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(50079): show deprecated on JSX attributes (#50084)
This commit is contained in:
parent
5df09a514c
commit
bcf994996e
@ -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);
|
||||
|
||||
25
tests/cases/fourslash/jsdocDeprecated_suggestion18.ts
Normal file
25
tests/cases/fourslash/jsdocDeprecated_suggestion18.ts
Normal file
@ -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
|
||||
},
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user