Home > other >  Can you change from `type` to `interface`?
Can you change from `type` to `interface`?

Time:03-16

I have types/interfaces that describe my API:

export type AddFileRequestApi = FormData

export interface AddMessageRequestApi {
  text: string;
  date: string;
}

Can I change export type AddFileRequestApi = FormData to use interface? E.g. something like this:

export interface AddFileRequestApi extends FormData

CodePudding user response:

1

Yes, just add an empty body at the end ({}), since the body part of an interface isn't optional; example (more here). But why? And why have a type that's just an alias for FormData? – T.J. Crowder 23 mins ago

  • Related