Skip to content

Commit

Permalink
chore: upgrade example deps (#101)
Browse files Browse the repository at this point in the history
* chore: upgrade example deps

* fix: fix test case
  • Loading branch information
xuchaobei authored Dec 23, 2022
1 parent 29acadb commit 1432ec1
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 136 deletions.
2 changes: 1 addition & 1 deletion examples/todos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@modern-js-reduck/react": "*",
"@modern-js-reduck/react": "latest",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"preview": "vite preview"
},
"dependencies": {
"@modern-js-reduck/react": "*",
"@modern-js-reduck/react": "latest",
"react": "^18.0.2",
"react-dom": "^18.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-counter/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useModel } from '@modern-js-reduck/react';
import { modelA, modelB } from './model/count';
function App() {
const [state, actions] = useModel([modelA, modelB]);
const [state, actions] = useModel(modelA, modelB);

return (
<div>
Expand Down
6 changes: 6 additions & 0 deletions examples/vite-counter/src/model/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export const modelA = model('modelA').define({
state: {
a: 1,
},
computed: {
// add1: (state) => state.a + 1
},
actions: {
incA(s) {
return { a: s.a + 1 };
Expand All @@ -14,6 +17,9 @@ export const modelB = model('modelB').define({
state: {
b: 1,
},
computed: {
add2: (state) => state.b + 1
},
actions: {
incB(s) {
return { b: s.b + 1 };
Expand Down
2 changes: 1 addition & 1 deletion examples/with-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@modern-js-reduck/react": "*",
"@modern-js-reduck/react": "latest",
"react": "^18.0.2",
"react-dom": "^18.0.2",
"react-scripts": "5.0.1",
Expand Down
9 changes: 5 additions & 4 deletions packages/store/src/__tsd__/model.tsd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expectType, expectAssignable } from 'tsd';
import { useModel } from '@modern-js/runtime/model';
import { model } from '..';
import { ReduxAction } from '@/types';

type StateManual = { count: number; name: 'a' | 'b' };
const counterManual = model<StateManual>('counter').define({
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('action and state manually type', () => {
expectType<(s: StateManual) => void>(counterManual._.actions.empty);
const [state, actions] = useModel(counterManual);
expectType<StateManual>(state);
expectType<(n: number) => void>(actions.add);
expectType<(n: number) => ReduxAction<number>>(actions.add);
});

describe('action and state auto infer', () => {
Expand All @@ -61,7 +62,7 @@ describe('action and state auto infer', () => {
expectType<(s: StateInfer) => void>(counterInfer._.actions.empty);
const [state, actions] = useModel(counterInfer);
expectType<StateInfer>(state);
expectType<(n: number) => void>(actions.add);
expectType<(n: number) => ReduxAction<number>>(actions.add);
});

describe('action and state union type', () => {
Expand Down Expand Up @@ -92,6 +93,6 @@ describe('action and state function Initial', () => {
counter._.actions.add,
);
expectType<number>(state.c);
expectType<() => void>(actions.test.a);
expectType<(n: number) => void>(actions.test.b);
expectType<() => ReduxAction<undefined>>(actions.test.a);
expectType<(n: number) => ReduxAction<number>>(actions.test.b);
});
Loading

0 comments on commit 1432ec1

Please sign in to comment.