Skip to content

Commit

Permalink
Make new fixture a unit test, add a few more.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwilsonvu committed Apr 13, 2024
1 parent 52e650b commit a3f07a2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
8 changes: 8 additions & 0 deletions docs/reactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ function createFoo(v) {}
const [bar, setBar] = createSignal();
createFoo([bar]);

function createFoo(v) {}
const [bar, setBar] = createSignal();
createFoo({ onBar: () => bar() } as object);

const [bar, setBar] = createSignal();
X.createFoo(() => bar());

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

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

const [s] = createSignal("a" as string);

createFoo("a" as string);

function Component(props) {
return (
<div>
Expand Down
11 changes: 0 additions & 11 deletions test/fixture/valid/as-expression/main.tsx

This file was deleted.

17 changes: 14 additions & 3 deletions test/rules/reactivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ export const cases = run("reactivity", rule, {
`function createFoo(v) {}
const [bar, setBar] = createSignal();
createFoo([bar]);`,
// `function createFoo(v) {}
// const [bar, setBar] = createSignal();
// createFoo((() => () => bar())());`,
{
code: `function createFoo(v) {}
const [bar, setBar] = createSignal();
createFoo({ onBar: () => bar() } as object);`,
...tsOnlyTest,
},
`const [bar, setBar] = createSignal();
X.createFoo(() => bar());`,
`const [bar, setBar] = createSignal();
Expand Down Expand Up @@ -308,6 +311,14 @@ export const cases = run("reactivity", rule, {
code: `const m = createMemo(() => 5) satisfies Accessor<number>;`,
...tsOnlyTest,
},
{
code: `const [s] = createSignal('a' as string)`,
...tsOnlyTest,
},
{
code: `createFoo('a' as string)`,
...tsOnlyTest,
},
// functions in JSXExpressionContainers
`function Component(props) {
return (
Expand Down

0 comments on commit a3f07a2

Please sign in to comment.