Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Generics in actions are not added to type declarations #37

Open
supun-io opened this issue Aug 3, 2022 · 0 comments
Open

Generics in actions are not added to type declarations #37

supun-io opened this issue Aug 3, 2022 · 0 comments

Comments

@supun-io
Copy link

supun-io commented Aug 3, 2022

Environment

  • kea-typegen version: 3.0.0
  • kea version: 3.0.1
  • typescript version: 4.6.4

This logic:

import {Post} from './types';

const postLogic = kea<postLogicType>([
    actions({
         updateValue: <T extends keyof Post>(key: T, value: Post[T]) => ({key, value})
    })
])

Produces this type:

export interface postLogicType extends Logic {
     actionCreators: {
        updateValue: (key: T, value: Post[T]) => ({
            type: "update post value (post.*)";
            payload: {
                key: T;
                value: PostVariant[T];
            };
        });
    },
    actions: {
        updateValue: (key: T, value: PostVariant[T]) => void;
    }
}

In both actionCreators and actions, the generic T is added, but there is no reference to T (Therefore typescript code is invalid).

It should instead:

It should add <T extends keyof Post> in function definitions within actionCreators and actions.

(Unless there is another way to use generics in actions?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant