0

I want to create an interface with an unknown number of properties of type string in typescript. eg: there could be 5 or maybe 50 property of type string Is it possible in typescript?

1 Answer 1

2

You can try this to specify that a interface can have any number of properties:

interface MyInterface {
  knownPropert1: string;
  knownProperty2: string;
  [key: string]: string; // specify that any other properties will be of type string too
}
Sign up to request clarification or add additional context in comments.

Comments

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.