@@ -872,6 +872,69 @@ ${' '}
872872 ` ,
873873 features : [ 'ts' , 'no-babel' ] ,
874874 } ,
875- ] : [ ]
875+ ] : [ ] ,
876+ {
877+ code : `
878+ type Props = { text: string };
879+ export const MyComponent: React.FC<Props> = (props) => {
880+ type MyType = typeof props.text;
881+ return <div>{props.text as MyType}</div>;
882+ };
883+ ` ,
884+ options : [ 'always' , { destructureInSignature : 'always' } ] ,
885+ features : [ 'types' , 'no-babel' ] ,
886+ errors : [
887+ {
888+ messageId : 'useDestructAssignment' ,
889+ type : 'TSQualifiedName' ,
890+ data : { type : 'props' } ,
891+ } ,
892+ {
893+ messageId : 'useDestructAssignment' ,
894+ type : 'MemberExpression' ,
895+ data : { type : 'props' } ,
896+ } ,
897+ ] ,
898+ } ,
899+ {
900+ code : `
901+ type Props = { text: string };
902+ export const MyOtherComponent: React.FC<Props> = (props) => {
903+ const { text } = props;
904+ type MyType = typeof props.text;
905+ return <div>{text as MyType}</div>;
906+ };
907+ ` ,
908+ options : [ 'always' , { destructureInSignature : 'always' } ] ,
909+ features : [ 'types' , 'no-babel' ] ,
910+ errors : [
911+ {
912+ messageId : 'useDestructAssignment' ,
913+ type : 'TSQualifiedName' ,
914+ data : { type : 'props' } ,
915+ } ,
916+ ] ,
917+ } ,
918+ {
919+ code : `
920+ function C(props: Props) {
921+ void props.a
922+ typeof props.b
923+ return <div />
924+ }
925+ ` ,
926+ options : [ 'always' ] ,
927+ features : [ 'types' ] ,
928+ errors : [
929+ {
930+ messageId : 'useDestructAssignment' ,
931+ data : { type : 'props' } ,
932+ } ,
933+ {
934+ messageId : 'useDestructAssignment' ,
935+ data : { type : 'props' } ,
936+ } ,
937+ ] ,
938+ }
876939 ) ) ,
877940} ) ;
0 commit comments