T
T
tyoma_koder2021-10-20 16:41:51
Angular
tyoma_koder, 2021-10-20 16:41:51

Why writes that types are incompatible?

There is an interface

export interface Applications {
  "date": string,
  "firm": string,
  "full name": string,
  "phone": string,
  "comment": string,
  "code": string
}

I am trying to pass a variable with this data type to a post request
this.body = new HttpParams({
      fromObject: this.variable
})

But for some reason it writes to me that
Type 'Applications' is not assignable to type '{ [param: string]: string | number | boolean | readonly (string | number | boolean)[]; }'.

The interface completely matches the type in the error, what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-10-20
@tyoma_koder

You continue to read that message:

Type 'Applications' is not assignable to type '{ [param: string]: string | number | boolean | readonly (string | number | boolean)[]; }'.
Index signature for type 'string' is missing in type 'Applications'

This is how it will work:
export type Applications = {
  "date": string,
  "firm": string,
  "full name": string,
  "phone": string,
  "comment": string,
  "code": string
}

What the hell is this your Index signature google yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question