Skip to content

Commit a3f07a2

Browse files
committed
Make new fixture a unit test, add a few more.
1 parent 52e650b commit a3f07a2

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

docs/reactivity.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ function createFoo(v) {}
645645
const [bar, setBar] = createSignal();
646646
createFoo([bar]);
647647

648+
function createFoo(v) {}
649+
const [bar, setBar] = createSignal();
650+
createFoo({ onBar: () => bar() } as object);
651+
648652
const [bar, setBar] = createSignal();
649653
X.createFoo(() => bar());
650654

@@ -812,6 +816,10 @@ const m = createMemo(() => 5)! as Accessor<number>;
812816

813817
const m = createMemo(() => 5) satisfies Accessor<number>;
814818

819+
const [s] = createSignal("a" as string);
820+
821+
createFoo("a" as string);
822+
815823
function Component(props) {
816824
return (
817825
<div>

test/fixture/valid/as-expression/main.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/rules/reactivity.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ export const cases = run("reactivity", rule, {
158158
`function createFoo(v) {}
159159
const [bar, setBar] = createSignal();
160160
createFoo([bar]);`,
161-
// `function createFoo(v) {}
162-
// const [bar, setBar] = createSignal();
163-
// createFoo((() => () => bar())());`,
161+
{
162+
code: `function createFoo(v) {}
163+
const [bar, setBar] = createSignal();
164+
createFoo({ onBar: () => bar() } as object);`,
165+
...tsOnlyTest,
166+
},
164167
`const [bar, setBar] = createSignal();
165168
X.createFoo(() => bar());`,
166169
`const [bar, setBar] = createSignal();
@@ -308,6 +311,14 @@ export const cases = run("reactivity", rule, {
308311
code: `const m = createMemo(() => 5) satisfies Accessor<number>;`,
309312
...tsOnlyTest,
310313
},
314+
{
315+
code: `const [s] = createSignal('a' as string)`,
316+
...tsOnlyTest,
317+
},
318+
{
319+
code: `createFoo('a' as string)`,
320+
...tsOnlyTest,
321+
},
311322
// functions in JSXExpressionContainers
312323
`function Component(props) {
313324
return (

0 commit comments

Comments
 (0)