Design comparison
Solution retrospective
I'm pretty new to typescript and I want to fix this one thing. Currently in the notification.type.ts the data property of the notification type is any. I want this data type to change depending on the given notificationType.
For example: if the type of notification is 'private-message' i want the type of 'data' to be { message: { content: String } } How can I achieve this? Thanks in advance
Community feedback
- @eruj22Posted about 2 years ago
Hi Richard,
one way you could replace type any is with the following type:
type Data = { post?: { id: number; picture?: string; title?: string; }; message?: { data: string; }; group?: { id: number; name: string; }; };
This way you have all the different types covered.
Regarding the other code I can only suggest refactoring files inside NotificationItems. Some notifications seems really similar and could be merged into one file with some props added to them.
Have fun improving your little project.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord