Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing to support readonly array properties of AST Node #15127

Merged
merged 4 commits into from Jul 21, 2023

Conversation

auvred
Copy link
Contributor

@auvred auvred commented Jul 18, 2023

Description

Closes: #15034

TS Playground

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

/** After */
// Now works fine too
path.map(() => "", "readonlyArray");
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Prettier stable and Prettier main instead of before/after. https://github.com/prettier/prettier/blob/main/changelog_unreleased/TEMPLATE.md

@fisker
Copy link
Member

fisker commented Jul 18, 2023

Is it possible to test here? https://github.com/prettier/prettier/tree/main/tests/dts

@auvred
Copy link
Contributor Author

auvred commented Jul 18, 2023

I guess I can add it here

interface PluginAST {
kind: "line";
value: string;
}

@fisker
Copy link
Member

fisker commented Jul 18, 2023

As I tested, if I remove added readonly. The test hangs.

$ yarn jest tests/dts
DeprecationWarning: 'originalKeywordKind' has been deprecated since v5.0.0 and will no longer be usable after v5.2.0. Use 'identifierToKeywordKind(identifier)' instead.
 FAIL  tests/dts/unit/run.js
  ● Test suite failed to run

    Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory



Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        94.418 s
Ran all test suites matching /tests\/dts/i.

@auvred
Copy link
Contributor Author

auvred commented Jul 18, 2023

This seems related: #15034 (comment)

Very weird...

@sosukesuzuki sosukesuzuki merged commit ceed405 into prettier:main Jul 21, 2023
29 checks passed
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 15, 2024
…er#15127)

* Add typing to support `readonly` array properties of AST Node

* add changelog

* fix changelog

* add test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypesScript types issue with node with readonly array and .map, .each on AstPath
3 participants