Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: should run preapre before publish #128

Merged
merged 5 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/angry-buses-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@modern-js-reduck/plugin-auto-actions': patch
'@modern-js-reduck/plugin-devtools': patch
'@modern-js-reduck/plugin-effects': patch
'@modern-js-reduck/plugin-immutable': patch
'@modern-js-reduck/react': patch
'@modern-js-reduck/store': patch
---

fix: should run prepare before publish
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"bump": "modern bump",
"pre": "modern pre",
"release": "modern release",
"prepare": "husky install",
"prepare": "pnpm run --filter './packages/**' prepare && husky install",
"preinstall": "only-allow-pnpm",
"gen-release-note": "modern gen-release-note",
"get-release-version": "cd scripts && pnpm run get-release-version"
Expand Down
182 changes: 91 additions & 91 deletions packages/store/src/__tsd__/model.tsd.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
import { expectType, expectAssignable } from 'tsd';
import { useModel } from '@modern-js/runtime/model';
import { model } from '..';
import { ReduxAction } from '@/types';
// 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({
state: { count: 1 },
actions: {
add(state, n: number) {
expectType<StateManual>(state);
return { count: state.count + n, name: 'a' };
},
empty(state) {
expectType<StateManual>(state);
},
test: {
a(s) {
return s;
},
},
},
});
// type StateManual = { count: number; name: 'a' | 'b' };
// const counterManual = model<StateManual>('counter').define({
// state: { count: 1 },
// actions: {
// add(state, n: number) {
// expectType<StateManual>(state);
// return { count: state.count + n, name: 'a' };
// },
// empty(state) {
// expectType<StateManual>(state);
// },
// test: {
// a(s) {
// return s;
// },
// },
// },
// });

type StateInfer = { count: number; name: string };
const counterInfer = model('counter').define({
state: { count: 1, name: 'a' },
actions: {
add(state, n: number) {
expectType<StateInfer>(state);
return { count: state.count + n, name: 'b' };
},
empty(state) {
expectType<StateInfer>(state);
},
test: {
a(state) {
expectType<StateInfer>(state);
return state;
},
},
},
});
// type StateInfer = { count: number; name: string };
// const counterInfer = model('counter').define({
// state: { count: 1, name: 'a' },
// actions: {
// add(state, n: number) {
// expectType<StateInfer>(state);
// return { count: state.count + n, name: 'b' };
// },
// empty(state) {
// expectType<StateInfer>(state);
// },
// test: {
// a(state) {
// expectType<StateInfer>(state);
// return state;
// },
// },
// },
// });

describe('action and state manually type', () => {
expectType<string>(counterManual.name);
// describe('action and state manually type', () => {
// expectType<string>(counterManual.name);

expectAssignable<(s: StateManual, n: number) => StateManual>(
counterManual._.actions.add,
);
expectType<(s: StateManual) => void>(counterManual._.actions.empty);
const [state, actions] = useModel(counterManual);
expectType<StateManual>(state);
expectType<(n: number) => ReduxAction<number>>(actions.add);
});
// expectAssignable<(s: StateManual, n: number) => StateManual>(
// counterManual._.actions.add,
// );
// expectType<(s: StateManual) => void>(counterManual._.actions.empty);
// const [state, actions] = useModel(counterManual);
// expectType<StateManual>(state);
// expectType<(n: number) => ReduxAction<number>>(actions.add);
// });

describe('action and state auto infer', () => {
expectType<string>(counterInfer.name);
expectType<(s: StateInfer, n: number) => StateInfer>(
counterInfer._.actions.add,
);
expectType<(s: StateInfer) => void>(counterInfer._.actions.empty);
const [state, actions] = useModel(counterInfer);
expectType<StateInfer>(state);
expectType<(n: number) => ReduxAction<number>>(actions.add);
});
// describe('action and state auto infer', () => {
// expectType<string>(counterInfer.name);
// expectType<(s: StateInfer, n: number) => StateInfer>(
// counterInfer._.actions.add,
// );
// expectType<(s: StateInfer) => void>(counterInfer._.actions.empty);
// const [state, actions] = useModel(counterInfer);
// expectType<StateInfer>(state);
// expectType<(n: number) => ReduxAction<number>>(actions.add);
// });

describe('action and state union type', () => {
const [state] = useModel(counterManual);
expectType<'a' | 'b'>(state.name);
});
// describe('action and state union type', () => {
// const [state] = useModel(counterManual);
// expectType<'a' | 'b'>(state.name);
// });

describe('action and state function Initial', () => {
const counter = model('counter').define(() => ({
state: { c: 1 },
actions: {
add(state, payload: number) {
expectType<number>(state.c);
return { c: state.c + payload };
},
test: {
a(s) {
return s;
},
b(s, p: number) {
return { ...s, c: s.c + p };
},
},
},
}));
const [state, actions] = useModel(counter);
expectType<(s: { c: number }, n: number) => { c: number }>(
counter._.actions.add,
);
expectType<number>(state.c);
expectType<() => ReduxAction<undefined>>(actions.test.a);
expectType<(n: number) => ReduxAction<number>>(actions.test.b);
});
// describe('action and state function Initial', () => {
// const counter = model('counter').define(() => ({
// state: { c: 1 },
// actions: {
// add(state, payload: number) {
// expectType<number>(state.c);
// return { c: state.c + payload };
// },
// test: {
// a(s) {
// return s;
// },
// b(s, p: number) {
// return { ...s, c: s.c + p };
// },
// },
// },
// }));
// const [state, actions] = useModel(counter);
// expectType<(s: { c: number }, n: number) => { c: number }>(
// counter._.actions.add,
// );
// expectType<number>(state.c);
// expectType<() => ReduxAction<undefined>>(actions.test.a);
// expectType<(n: number) => ReduxAction<number>>(actions.test.b);
// });