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 babel-bot commented Aug 11, 2021

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

@codesandbox
Copy link

@codesandbox codesandbox 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 approved these changes Aug 11, 2021
@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Aug 11, 2021

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 issue 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

@jridgewell jridgewell commented Aug 11, 2021

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

@jridgewell jridgewell Aug 15, 2021

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

@nicolo-ribaudo nicolo-ribaudo Aug 16, 2021

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

@JLHwung JLHwung Aug 16, 2021

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

@jridgewell jridgewell Aug 16, 2021

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 Aug 16, 2021
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 Aug 16, 2021
@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
26 of 28 checks passed
@jridgewell jridgewell deleted the aliased-types branch Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants