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

type error in PostStats.tsx (solution) #59

Closed
SteaceP opened this issue May 16, 2024 · 0 comments
Closed

type error in PostStats.tsx (solution) #59

SteaceP opened this issue May 16, 2024 · 0 comments

Comments

@SteaceP
Copy link

SteaceP commented May 16, 2024

If you're like me and NEED to use the latest version of everything and you got a type error on save in currentUser?.save in savedPostRecord const in the PostStats.tsx file.

add this code to /src/types/index.ts IUser type:

save?: Array<{
 $id: string;
  post: {
    $id: string;
  };
 }>;
};

then, in PostStats.tsx, make the savedPostrecord const like this:

  const savedPostRecord = (currentUser as IUser)?.save?.find(
    (record: { $id: string; post: { $id: string } }) => record.post.$id === post.$id,
  );

enjoy!
Sorry for not making a pull request, I'm not sure it will break something later and don't have time to check. If it does I'' be updating this.
Edit: I just had a new(probably with my previous update) a new type error. Again the same. The IUser type is all fucked up, i'll be updati Edit: I just had a new(probably with my previous update) a new type error. Again the same. The IUser type is all fucked up, i'll be updating this

then, in PostStats.tsx, make the savedPostrecord const like this:

  const savedPostRecord = (currentUser as IUser)?.save?.find(
    (record: { $id: string; post: { $id: string } }) => record.post.$id === post.$id,
  );

enjoy!
Sorry for not making a pull request, I'm not sure it will break something later and don't have time to check. If it does I'' be updating this.
Edit: I just had a new(probably with my previous update) type error. Again, it's the same. The IUser type is all fucked up, i'll be updating this code from now on since the person who made it seems to be dead or something like that, well, I'll fork this and try to keep it updated, i'll give the link once it's done (on next weekend). To the guy with the unpronounceable name that speak english better than all of us (british are excluded from this debate) I can just make a pull request if you somehow raise from the dead(ressurectMe).pls

@SteaceP SteaceP closed this as completed May 20, 2024
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