@@ -6995,6 +6995,18 @@ const testsTypescript = {
6995
6995
}
6996
6996
` ,
6997
6997
} ,
6998
+ {
6999
+ code : normalizeIndent `
7000
+ function App() {
7001
+ const foo = {x: 1};
7002
+ React.useEffect(() => {
7003
+ const bar = {x: 2};
7004
+ const baz = bar as typeof foo;
7005
+ console.log(baz);
7006
+ }, []);
7007
+ }
7008
+ ` ,
7009
+ } ,
6998
7010
] ,
6999
7011
invalid : [
7000
7012
{
@@ -7028,6 +7040,40 @@ const testsTypescript = {
7028
7040
} ,
7029
7041
] ,
7030
7042
} ,
7043
+ {
7044
+ code : normalizeIndent `
7045
+ function App() {
7046
+ const foo = {x: 1};
7047
+ const bar = {x: 2};
7048
+ useEffect(() => {
7049
+ const baz = bar as typeof foo;
7050
+ console.log(baz);
7051
+ }, []);
7052
+ }
7053
+ ` ,
7054
+ errors : [
7055
+ {
7056
+ message :
7057
+ "React Hook useEffect has a missing dependency: 'bar'. " +
7058
+ 'Either include it or remove the dependency array.' ,
7059
+ suggestions : [
7060
+ {
7061
+ desc : 'Update the dependencies array to be: [bar]' ,
7062
+ output : normalizeIndent `
7063
+ function App() {
7064
+ const foo = {x: 1};
7065
+ const bar = {x: 2};
7066
+ useEffect(() => {
7067
+ const baz = bar as typeof foo;
7068
+ console.log(baz);
7069
+ }, [bar]);
7070
+ }
7071
+ ` ,
7072
+ } ,
7073
+ ] ,
7074
+ } ,
7075
+ ] ,
7076
+ } ,
7031
7077
{
7032
7078
code : normalizeIndent `
7033
7079
function MyComponent() {
@@ -7233,7 +7279,7 @@ const testsTypescript = {
7233
7279
code : normalizeIndent `
7234
7280
function MyComponent() {
7235
7281
const [state, setState] = React.useState<number>(0);
7236
-
7282
+
7237
7283
useEffect(() => {
7238
7284
const someNumber: typeof state = 2;
7239
7285
setState(prevState => prevState + someNumber + state);
@@ -7253,7 +7299,7 @@ const testsTypescript = {
7253
7299
output : normalizeIndent `
7254
7300
function MyComponent() {
7255
7301
const [state, setState] = React.useState<number>(0);
7256
-
7302
+
7257
7303
useEffect(() => {
7258
7304
const someNumber: typeof state = 2;
7259
7305
setState(prevState => prevState + someNumber + state);
@@ -7269,7 +7315,7 @@ const testsTypescript = {
7269
7315
code : normalizeIndent `
7270
7316
function MyComponent() {
7271
7317
const [state, setState] = React.useState<number>(0);
7272
-
7318
+
7273
7319
useMemo(() => {
7274
7320
const someNumber: typeof state = 2;
7275
7321
console.log(someNumber);
@@ -7287,7 +7333,7 @@ const testsTypescript = {
7287
7333
output : normalizeIndent `
7288
7334
function MyComponent() {
7289
7335
const [state, setState] = React.useState<number>(0);
7290
-
7336
+
7291
7337
useMemo(() => {
7292
7338
const someNumber: typeof state = 2;
7293
7339
console.log(someNumber);
0 commit comments