0

I have a Typescript interface

export interface MyInterface {
  valid: boolean;
  resourceType: MyEnum;
  message: string;
}

and an enum

enum MyEnum {
  'a',
  'b',
  'c'
}

Is it possible to allow the value of MyInterface.resourceType to be any value from MyEnum?

Currently my IDE is throwing an error

property 'resourceType' of exported interface has or is using private 
name 'MyEnum'
2
  • 4
    Read the error message carefully. You need to export enum MyEnum { ... }, so that other parts of the app can access it to see what valid values there are. Commented Jul 18, 2018 at 21:03
  • Wow I can't believe I missed something so simple haha. Thank you! Commented Jul 19, 2018 at 12:55

1 Answer 1

2

Try exporting the enum

export enum MyEnum {
  a = 'a',
  b = 'b',
  c = 'c'
}
Sign up to request clarification or add additional context in comments.

1 Comment

Wow I can't believe I missed something so simple haha. Thank you!

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.