Convert Array to Interface Array


On an Angular 12 application I have the following environment:

export const environment = {
  production: false,
  applications: [
    { name: "Api", url: "https://localhost:5001" },
    { name: "Bot", url: "https://localhost:5003"}

And I create an Application interface and EnvironmentService class:

export interface Application {
  name: string;
  url: string;

export class EnvironmentService {

  constructor() {}

  get production() : boolean { return environment.production; }

  get applications() : Application[] { return environment.applications };


But I get an error:

Type '{ name: string; url: string; }[]' is not assignable to type 'Application[]'.

How can I convert environment.applications to Application[]?

Source: Angular Questions

Categorized as angular, angular12, typescript Tagged , ,


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us