@@ -205,6 +205,30 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
205
205
}
206
206
` ,
207
207
// #endregion valid; void return return value
208
+ // #region valid; void return variable
209
+ {
210
+ code : stripIndent `
211
+ // void return variable; explicitly allowed
212
+ import { Observable, of } from "rxjs";
213
+
214
+ let foo: () => void;
215
+ foo = (): Observable<number> => of(42);
216
+ ` ,
217
+ options : [ { checksVoidReturn : false } ] ,
218
+ } ,
219
+ stripIndent `
220
+ // void return variable; not void
221
+ import { Observable, of } from "rxjs";
222
+
223
+ let foo: () => Observable<number>;
224
+ foo = () => of(42);
225
+ ` ,
226
+ stripIndent `
227
+ // void return variable; unrelated
228
+ let foo: () => void;
229
+ foo = (): number => 42;
230
+ ` ,
231
+ // #endregion valid; void return variable
208
232
// #region valid; spread
209
233
{
210
234
code : stripIndent `
@@ -721,6 +745,40 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
721
745
` ,
722
746
) ,
723
747
// #endregion invalid; void return return value
748
+ // #region invalid; void return variable
749
+ fromFixture (
750
+ stripIndent `
751
+ // void return variable; reassign
752
+ import { of } from "rxjs";
753
+
754
+ let foo: () => void;
755
+ foo = () => of(42);
756
+ ~~~~~~~~~~~~ [forbiddenVoidReturnVariable]
757
+ ` ,
758
+ ) ,
759
+ fromFixture (
760
+ stripIndent `
761
+ // void return variable; nested
762
+ import { of } from "rxjs";
763
+
764
+ const foo: {
765
+ bar?: () => void;
766
+ } = {};
767
+ foo.bar = () => of(42);
768
+ ~~~~~~~~~~~~ [forbiddenVoidReturnVariable]
769
+ ` ,
770
+ ) ,
771
+ fromFixture (
772
+ stripIndent `
773
+ // void return variable; Record
774
+ import { of } from "rxjs";
775
+
776
+ const foo: Record<string, () => void> = {};
777
+ foo.bar = () => of(42);
778
+ ~~~~~~~~~~~~ [forbiddenVoidReturnVariable]
779
+ ` ,
780
+ ) ,
781
+ // #endregion invalid; void return variable
724
782
// #region invalid; spread
725
783
fromFixture (
726
784
stripIndent `
0 commit comments