Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

its possible to add any value in interface Props for initialization in React Typescript?

I need some help, I’m just learning typescript, I want to limit my finco’s value, but I can’t do it my way, Is this possible? like this

interface Props {
  finco?: string = 'TAF' | 'ACC'
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

interface Props {
  finco?: 'TAF' | 'ACC'
}

If you just put 'TAF' | 'ACC' as the type, Typescript will only accept one of those two values as value of a the finco field.
(well, and also undefined)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading