mattpocock / ts-error-translator

VSCode extension to turn TypeScript errors into plain English
https://ts-error-translator.vercel.app
2.36k stars 90 forks source link

Translation request for 4104 #240

Open nicolasdaudin opened 9 months ago

nicolasdaudin commented 9 months ago

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: