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 all missing babel-core option properties and alphabetize for better maintainability. #19428

Merged
merged 5 commits into from Sep 7, 2017

Conversation

amiller-gh
Copy link
Contributor

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://babeljs.io/docs/usage/api/#options
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

@dt-bot
Copy link
Member

dt-bot commented Aug 29, 2017

types/babel-core/index.d.ts

to authors (@yortus @marvinhagemeister). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

@typescript-bot typescript-bot added The Travis CI build failed Revision needed This PR needs code changes before it can be merged. labels Aug 29, 2017
@typescript-bot
Copy link
Contributor

@amiller-gh Please fix the failures indicated in the Travis CI log.

@thorn0
Copy link
Contributor

thorn0 commented Aug 29, 2017

Using types Object and Function is almost never a good idea. It's almost always (approx. in 99.99% of cases) possible to specify a better type.

@amiller-gh
Copy link
Contributor Author

amiller-gh commented Sep 1, 2017

Will update – saw it used elsewhere in the file for Babylon config passthroughs, thought it may be okay.

@thorn0
Copy link
Contributor

thorn0 commented Sep 1, 2017

You must have seen object, not Object.

Why not import BabylonOptions from the definitions for Babylon?

…properties alphabetically for maintainability.
@amiller-gh
Copy link
Contributor Author

amiller-gh commented Sep 4, 2017

PR updated with a much less lazy change – Now all missing Babel Core options have been added, and all the options have been alphabetized like in the Babel documentation.

@typescript-bot typescript-bot removed The Travis CI build failed Revision needed This PR needs code changes before it can be merged. labels Sep 4, 2017
@@ -10,10 +10,12 @@ export { t as types };
export type Node = t.Node;
export import template = require('babel-template');
export const version: string;
import traverse, { Visitor } from "babel-traverse";
import traverse, { Visitor, NodePath } from "babel-traverse";
Copy link
Contributor

Choose a reason for hiding this comment

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

This NodePath isn't used. Did you want to use it for wrapPluginVisitorMethod?

The rest looks great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left over from my trying to get wrapPluginVisitorMethod to have better specified types – was going to ask about that actually. The callback function it takes and the function it returns can take any NodePath variant. I couldn't come up with a way to add concrete typing to those functions without enumerating every templated type, like is done in babel-traverse. Do you have a better way to do this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Simple NodePath (AKA NodePath<Node>) is okay in this case.

@amiller-gh amiller-gh changed the title Add parserOpts to TransformOptions interface for @types/babel-core Add all missing babel-core option properties and alphabetize for better maintainability. Sep 4, 2017
@typescript-bot
Copy link
Contributor

@thorn0 - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate?

@@ -10,10 +10,12 @@ export { t as types };
export type Node = t.Node;
export import template = require('babel-template');
export const version: string;
import traverse, { Visitor } from "babel-traverse";
import traverse, { Visitor, NodePath } from "babel-traverse";
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple NodePath (AKA NodePath<Node>) is okay in this case.


/** Specify a custom name for module ids. */
moduleId?: string;
wrapPluginVisitorMethod?(pluginAlias: string, visitorType: string, callback: (path: any, state: any) => void): (path: any, state: any) => void ;
Copy link
Contributor

Choose a reason for hiding this comment

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

trying to get wrapPluginVisitorMethod to have better specified types – was going to ask about that actually. The callback function it takes and the function it returns can take any NodePath variant.

That's why the parent type should be used - NodePath (same as NodePath<Node>). All the variants are assignable to it, and there is no possibility to infer the specific subtype from anywhere, so the user has to use type guards or assertions anyway to work with specific subtypes. Which is unlikely however because the wrapPluginVisitorMethod option is intended for simpler use cases, see the original PR babel/babel#3659.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're on it, visitorType can be typed as 'enter' | 'exit', can't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated 👍

@thorn0
Copy link
Contributor

thorn0 commented Sep 6, 2017

Looks good. 👍 Formally, I'm not a reviewer of this package, so now I think you need an approve from one of them.

Copy link
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@typescript-bot
Copy link
Contributor

Approved by a listed owner. PR ready to merge pending express review by a maintainer.

@typescript-bot typescript-bot added Other Approved This PR was reviewed and signed-off by a community member. Popular package This PR affects a popular package (as counted by NPM download counts). labels Sep 7, 2017
@sandersn sandersn merged commit 7a3b23d into DefinitelyTyped:master Sep 7, 2017
@sandersn sandersn removed this from Merge: Express in Pull Request Triage Backlog Sep 7, 2017
chriseppstein pushed a commit to linkedin/css-blocks that referenced this pull request Nov 30, 2017
* Enable new State / Substate method syntax

 - Bump css-blocks so correlations aren't enumerated. Update tests accordingly.
 - Remove explicit state import from blocks
 - States are now methods on Blocks and Classes
 - Static and dynamic substates may be passed to State methods
 - Add error checking for mis-use of boolean states
 - States with sub-states must be passed a value
 - Initial infrastructure added to construct boolean expressions
 - Use new css-block analysis introspection methods in tests
 - Move BlockObject lookup logic to ExpressionReader
 - Remove detailed ast and source data from Template when no longer needed.
 - Add new babel-core types file locally until DefinitelyTyped/DefinitelyTyped#19428 lands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Other Approved This PR was reviewed and signed-off by a community member. Popular package This PR affects a popular package (as counted by NPM download counts).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants