1

I have an API response like this:

{
  gender: 1,
  gender@formattedValue: "Male",
  category: 4,
  category@formattedValue: "Employee"
}

So it has lots of properties that are appended a @formattedValue.

Is it possible to create a typescript interface that automatically adds to every property @formattedValue? Of course leaving the original in tact, so intellisense shows both versions?

3
  • No, it isn't possible; concatenating string literals is not implemented Commented Jun 3, 2020 at 9:48
  • @OliverRadini thanks, so it means i have to manually add to all of them? Commented Jun 3, 2020 at 9:48
  • 1
    Unfortunately, as far as I can tell at the moment, it would mean that; it may be possible to do this by having a tool which searches for interfaces and creates a new interface with the additional adjusted properties Commented Jun 3, 2020 at 9:50

1 Answer 1

1

Unfortunately no, you can't define interfaces with computed properties.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.