1

I am currently having a problem where I have two interfaces, UserProfile & Interest. The code is as follows for the two interfaces:

export default interface UserProfile {
    userProfileId: string,
    rep: number,
    pfpUrl: string,
    bio: string,
    experience: "beginner" | "intermediate" | "expert",
    country: string,
    height: number,
    weight: number,
    age: number,
    createdAt: Date,
    updatedAt: Date,
    userId: string,
    interests: Interest[]
}

export default interface Interest {
    interestId: string;
    name: string;
    createdAt: Date;
    updatedAt: Date;
    UserProfiles: UserProfile[]
}

As shown both has a many to many relationship with each other. The problem is that an error occurs stating that 'Interest' cant be found maybe because it has not been initialized yet. If that is the case how would we solve such problem? I am just matching the structure of what my API returns. My API returns those structure when fetching for either UserProfile or Interest

1 Answer 1

3

The issue is that you're exporting both as default. Make one or both of your interfaces a regular named export and your problem should be solved.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! Why did I not see that!
No problem! Please don't forget to accept the answer so that others know the problem is solved :)
Sure, just have to wait for a few more minutes to be able to do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.