-2

I have a union type setup in the parent

export type Students = "fresher" | "secondYear" | 'finalYear' | 'postGrad';

Causing a circular dependency, now the obvious solution is to define this type in an external file. Is there a work around where the child can determine what is passed without having to import and define the type again in the props?

Edit sandbox here

https://codesandbox.io/s/adoring-thunder-b6f66t?file=/src/StudentView.tsx

This is not an issue in codesandbox but the circular dependency is in my eslint.

TommyD
  • 913
  • 3
  • 17
  • 32
  • 3
    Shouldn't the `type Props` contain `student: Students`? At the moment it seems like you are passing a component into itself? – DBS Mar 06 '23 at 10:27
  • When asking about circular dependencies, it's important to be clear what code is in what module. Right now, I can't tell what's in what module, making it really hard to answer the question (other than that @DBS seems to have found an issue that may be the cause). – T.J. Crowder Mar 06 '23 at 10:30
  • *"sandbox here"* Please put the necessary information **in** the question, not just linked. Three reasons: People shouldn't have to go off-site to help you; some sites are blocked for some users; and links rot, making the question and its answers useless to people in the future. Please put a [mcve] **in** the question. More: [*How do I ask a good question?*](/help/how-to-ask) and [*Something in my web site or project doesn't work. Can I just paste a link to it?*](https://meta.stackoverflow.com/questions/254428/) – T.J. Crowder Mar 06 '23 at 10:47

1 Answers1

-1

Your problem is typo mistake. Your type is called Students not Student

type Props = {
    student: Student**s**,
};

and then when importing type also

import { Student**s** } from "../content/StudentView";