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 aliases for Standardized, TypeScript, and Flow #13666

Merged
merged 8 commits into from Oct 28, 2021

Conversation

jridgewell
Copy link
Member

@jridgewell jridgewell commented Aug 11, 2021

Q                       A
License MIT

This helps with filter out the types. Eg, I'm concerned with just the core JS types, and in I can derive them via:

type Core = Exclude<t.Node, t.TypeScript | t.Flow>;

@babel-bot
Copy link
Collaborator

babel-bot commented Aug 11, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48190/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 11, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9da61e2:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@fedeci fedeci added PR: New Feature 🚀 A type of pull request used for our changelog categories pkg: types labels Aug 11, 2021
@nicolo-ribaudo nicolo-ribaudo added this to the v7.16.0 milestone Aug 11, 2021
@nicolo-ribaudo nicolo-ribaudo added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label Aug 11, 2021
@nicolo-ribaudo
Copy link
Member

We have docs on the website for aliases, but I don't remember if they are auto-generated.

jridgewell added a commit to babel/website that referenced this pull request Aug 11, 2021
Re: babel/babel#13666

Seems these docs were a bit out of date. We should probably automate this, I generated it by running

```bash
$ cd babel
$ node packages/babel-types/scripts/generators/docs.js > ../babel-website/docs/types.md
```
@jridgewell
Copy link
Member Author

Opened babel/website#2564 to update the docs.

@@ -217,6 +217,8 @@ const aliasDescriptions = {
"A cover of [Literal](https://tc39.es/ecma262/#sec-primary-expression-literals)s, [Regular Expression Literal](https://tc39.es/ecma262/#sec-primary-expression-regular-expression-literals)s and [Template Literal](https://tc39.es/ecma262/#sec-template-literals)s.",
Loop: "A cover of loop statements.",
Method: "A cover of object methods and class methods.",
Miscellaneous:
"A cover of non-standard AST types that are sometimes useful for development.",
Copy link
Contributor

@JLHwung JLHwung Aug 13, 2021

Choose a reason for hiding this comment

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

If we want to support type Core = Exclude<t.Node, t.TypeScript | t.Flow>;, why don't we add a Core alias? The Miscellaneous type is a bit vague: you don't know what is until you have checked its containing types.

We have core.ts for the spec and experimental.ts for proposals, since core types won't become experimental, we can add Core for core.ts and CoreAndProposals for core.ts and experimental.ts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I chose Standardized, Proposal, and StandardizedOrProposal for the aliases.

Copy link
Member

Choose a reason for hiding this comment

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

We cannot have the Proposal alias, otherwise when a proposal becomes stable we'll need a breaking change to remove it from there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @nicolo-ribaudo. I think we can start with only Standardized and TypeScript, and add more in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot have the Proposal alias, otherwise when a proposal becomes stable we'll need a breaking change to remove it from there.

That makes sense, I'll remove.

I think we can start with only Standardized and TypeScript, and add more in the future.

I'm gonna keep Flow, but agreed.

@jridgewell jridgewell changed the title Ensure non-standard AST types have an appropriate alias Add aliases for Standardized, Proposal, TypeScript, Flow, and Miscellaneous AST nodes Aug 15, 2021
jridgewell and others added 5 commits August 15, 2021 20:14
This helps with filter out the types. Eg, I'm concerned with just the core JS types, and in I can derive them via:

```typescript
type Core = Exclude<t.Node, t.TypeScript | t.Flow>;
```
@jridgewell jridgewell force-pushed the aliased-types branch 3 times, most recently from 33a4b35 to 84105a4 Compare August 16, 2021 01:42
@jridgewell jridgewell changed the title Add aliases for Standardized, Proposal, TypeScript, Flow, and Miscellaneous AST nodes Add aliases for Standardized, TypeScript, and Flow AST aliases Aug 16, 2021
@jridgewell jridgewell changed the title Add aliases for Standardized, TypeScript, and Flow AST aliases Add aliases for Standardized, TypeScript, and Flow Aug 16, 2021
@JLHwung JLHwung merged commit b179365 into babel:main Oct 28, 2021
@jridgewell jridgewell deleted the aliased-types branch October 28, 2021 18:27
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: types PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants