A
A
arenchilingaryan2021-05-22 22:57:24
JavaScript
arenchilingaryan, 2021-05-22 22:57:24

Why don't interfaces work?

Hello! There was a question on AssemblyScript technology

Everything seems to be fine, but for some reason the interfaces do not want to work. When building, they say that such types do not exist in the interface, although they do exist. I would be very grateful if someone could help ;)

index.ts

interface IResultItem {
  id: i32;
  type: string;
  date: string;
  from: string;
  from_id: i32;
  text: string;
}

export function add(
  result: IResultItem[] = [{ id: 1, type: "type", date: "25.25.2025", from: "rew", from_id: 123, text: "hello" }]
): IResultItem[] {
return result;
}


The errors are as follows:
60a96159471f6177713616.jpeg

Thanks in advance for your help :3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-05-23
@arenchilingaryan

In the ground they have a hat with documentation and examples. In none of the examples do they use objects at all, nor is there any instance of a typed object anywhere. From which I can conclude that they cannot work with typed objects at all. But this is not accurate .
For example, something like this works:

export class IResultItem {
  constructor(
    public id: i32,
    public type: string,
    public date: string,
    public from: string,
    public from_id: i32,
    public text: string
  ) {}
}
export function add(
  result: IResultItem[] = [new IResultItem( 1, "type", "25.25.2025", "rew", 123, "hello" )]
): IResultItem[] {
return result;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question