@@ -394,13 +394,64 @@ export default createRule<Options, MessageIds>({
394394 } ) ;
395395 }
396396
397+ function checkMemberExpression ( node : TSESTree . MemberExpression ) : void {
398+ if ( ! node . computed ) {
399+ return ;
400+ }
401+
402+ const propertyType = services . getTypeAtLocation ( node . property ) ;
403+
404+ if ( propertyType . isStringLiteral ( ) || propertyType . isLiteral ( ) ) {
405+ const objectType = services . getTypeAtLocation ( node . object ) ;
406+
407+ let propertyName : string | undefined ;
408+
409+ if ( propertyType . isStringLiteral ( ) ) {
410+ propertyName = propertyType . value ;
411+ } else if ( typeof propertyType . value === 'string' ) {
412+ propertyName = propertyType . value ;
413+ } else if ( typeof propertyType . value === 'number' ) {
414+ propertyName = String ( propertyType . value ) ;
415+ }
416+
417+ if ( ! propertyName ) {
418+ return ;
419+ }
420+
421+ const property = objectType . getProperty ( propertyName ) ;
422+
423+ const reason = getJsDocDeprecation ( property ) ;
424+ if ( reason == null ) {
425+ return ;
426+ }
427+
428+ if ( typeMatchesSomeSpecifier ( objectType , allow , services . program ) ) {
429+ return ;
430+ }
431+
432+ context . report ( {
433+ ...( reason
434+ ? {
435+ messageId : 'deprecatedWithReason' ,
436+ data : { name : propertyName , reason } ,
437+ }
438+ : {
439+ messageId : 'deprecated' ,
440+ data : { name : propertyName } ,
441+ } ) ,
442+ node : node . property ,
443+ } ) ;
444+ }
445+ }
446+
397447 return {
398448 Identifier : checkIdentifier ,
399449 JSXIdentifier ( node ) : void {
400450 if ( node . parent . type !== AST_NODE_TYPES . JSXClosingElement ) {
401451 checkIdentifier ( node ) ;
402452 }
403453 } ,
454+ MemberExpression : checkMemberExpression ,
404455 PrivateIdentifier : checkIdentifier ,
405456 Super : checkIdentifier ,
406457 } ;
0 commit comments