-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Copy link
Labels
area:type definitionIssues with *d.ts filesIssues with *d.ts fileslocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Environments:
- Prettier Version: 3.0.0
- Running Prettier via: n/a / TypeScript
- Runtime: Node v18.16.0, Typescript 5.1
- Operating System: MacOS
- Prettier plugins (if any): Issue happen when writing a plugin
Typescript produce an error when trying to use .map
for a property that is a readonly array.
Steps to reproduce:
Using the following typescript code will produce an error when trying to .map
a property that is a readonly array(same for .each
)
import { AstPath } from "prettier";
interface TestNode {
regularArray: string[];
readonlyArray: readonly string[];
}
const path: AstPath<TestNode> = undefined as any;
// Works fine
path.map(() => "", "regularArray");
// Ts error
path.map(() => "", "readonlyArray");
// ^ Argument of type '"readonlyArray"' is not assignable to parameter of type '"regularArray"'.ts(2345)
Expected behavior:
Should not be any difference between a readonly and regular array.
Actual behavior:
Typescript produce an error when trying to use .map
for a property that is a readonly array.
Metadata
Metadata
Assignees
Labels
area:type definitionIssues with *d.ts filesIssues with *d.ts fileslocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.