Skip to content

Commit c23d549

Browse files
committed
[Tests] failing tests for #3828
1 parent 9668ee0 commit c23d549

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/rules/destructuring-assignment.js

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ module.exports = {
257257
if (!propsRefs) {
258258
return;
259259
}
260+
260261
// Skip if props is used elsewhere
261262
if (propsRefs.length > 1) {
262263
return;

tests/lib/rules/destructuring-assignment.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,41 @@ ${' '}
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'],
886+
errors: [
887+
{
888+
messageId: 'useDestructAssignment',
889+
data: { type: 'props' },
890+
},
891+
],
892+
},
893+
{
894+
code: `
895+
type Props = { text: string };
896+
export const MyOtherComponent: React.FC<Props> = (props) => {
897+
const { text } = props;
898+
type MyType = typeof props.text;
899+
return <div>{text as MyType}</div>;
900+
};
901+
`,
902+
options: ['always', { destructureInSignature: 'always' }],
903+
features: ['types'],
904+
errors: [
905+
{
906+
messageId: 'destructureInSignature',
907+
data: { type: 'props' },
908+
},
909+
],
910+
}
876911
)),
877912
});

0 commit comments

Comments
 (0)