Skip to content
Open
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
39 changes: 39 additions & 0 deletions src/__tests__/e2e/__snapshots__/actions.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,42 @@ exports[`actions - with random values instead of functions 1`] = `
_isKeaWithKey: false;
}"
`;

exports[`actions - with generic 1`] = `
"export interface logicType extends Logic {
actionCreators: {
updateName: <T extends string>(name?: T) => ({
type: \\"update name (logic)\\";
payload: {
name: T;
};
});
};
actionKeys: {
\\"update name (logic)\\": \\"updateName\\";
};
actionTypes: {
updateName: \\"update name (logic)\\";
};
actions: {
updateName: <T extends string>(name?: T) => void;
};
defaults: {};
events: {};
key: undefined;
listeners: {};
path: [
\\"logic\\"
];
pathString: \\"logic\\";
props: Record<string, unknown>;
reducer: (state: any, action: any, fullState: any) => {};
reducers: {};
selector: (state: any) => {};
selectors: {};
sharedListeners: {};
values: {};
_isKea: true;
_isKeaWithKey: false;
}"
`;
13 changes: 13 additions & 0 deletions src/__tests__/e2e/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,16 @@ test('actions - with random values instead of functions', () => {
`
expect(logicSourceToLogicType(logicSource)).toMatchSnapshot()
})

test('actions - with generic', () => {
const logicSource = `
import { kea } from 'kea'

const logic = kea({
actions: {
updateName: <T extends string>(name?: T) => ({ name }),
}
})
`
expect(logicSourceToLogicType(logicSource)).toMatchSnapshot()
})