-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add typing to support
readonly
array properties of AST Node (#15127)
* Add typing to support `readonly` array properties of AST Node * add changelog * fix changelog * add test case
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#### Add typing to support `readonly` array properties of AST Node (#15127 by @auvred) | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
// Input | ||
interface TestNode { | ||
readonlyArray: readonly string[]; | ||
} | ||
|
||
declare const path: AstPath<TestNode>; | ||
|
||
path.map(() => "", "readonlyArray"); | ||
|
||
// Prettier stable | ||
interface TestNode { | ||
readonlyArray: readonly string[]; | ||
} | ||
|
||
declare const path: AstPath<TestNode>; | ||
|
||
path.map(() => "", "readonlyArray"); | ||
// ^ Argument of type '"readonlyArray"' is not assignable to parameter of type '"regularArray"'. ts(2345) | ||
|
||
// Prettier main | ||
interface TestNode { | ||
readonlyArray: readonly string[]; | ||
} | ||
|
||
declare const path: AstPath<TestNode>; | ||
|
||
path.map(() => "", "readonlyArray"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters