Home > Mobile >  How to create type for api response with fields name starting with number?
How to create type for api response with fields name starting with number?

Time:05-17

I have a api response like this

{
  "randomField": "data",
  "3withNumber": "data"
}

I want to create a type for it.

type ApiResponse {
    randomField: string,
    3withNumber: string
}

But as we cannot start the member name with a number. How can we handle this case?

CodePudding user response:

type ApiResponse = {
  randomField: string,
  '3withNumber': string
}
  • Related