ts-error-translator icon indicating copy to clipboard operation
ts-error-translator copied to clipboard

Translation request for 4104

Open nicolasdaudin opened this issue 1 year ago • 0 comments

Hi,

I have this

export const AUTHORIZED_AIRPORT_TYPES = ['large_airport', 'medium_airport'] as const;
export type AirportType = typeof AUTHORIZED_AIRPORT_TYPES[number];

And I'm trying to do this

async getAll(filters: AirportType[] = AUTHORIZED_AIRPORT_TYPES): Promise<Airport[]> {
    return await Array.from(this.airports.entries()).filter(([_, airport]) => filters.includes(airport.type)).map(([_, airport]) => airport)
  }

I get an ts4104 error on the method definition but I actually don't understand it.

Error Text

The type 'readonly ["large_airport", "medium_airport"]' is 'readonly' and cannot be assigned to the mutable type '("large_airport" | "medium_airport")[]'.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

nicolasdaudin avatar Nov 17 '23 12:11 nicolasdaudin