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

convert @babel/helper-function-name to TypeScript #12486

Merged

Conversation

zxbodya
Copy link
Contributor

@zxbodya zxbodya commented Dec 11, 2020

Q                       A
License MIT

@babel/helper-function-name part of #11578

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 11, 2020

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 11, 2020

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 1e1868f:

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

@nicolo-ribaudo nicolo-ribaudo added the Flow -> TS Tracking repository migration from Flow to TS label Dec 11, 2020
@JLHwung JLHwung force-pushed the ts-migration/babel-helper-function-name branch from 7607e40 to a64e701 Compare December 14, 2020 22:01
@@ -2,7 +2,7 @@ import getFunctionArity from "@babel/helper-get-function-arity";
import template from "@babel/template";
import * as t from "@babel/types";

const buildPropertyMethodAssignmentWrapper = template(`
const buildPropertyMethodAssignmentWrapper = template.statement(`
Copy link
Member

Choose a reason for hiding this comment

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

Q: Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this way it was more granular type (just t.Statement instead of union of all possible options - I remember in some place ts was complaining about possible array instead of ast node), however - later I anyway added more typecasts… so this is no longer needed - reverting it

@@ -150,7 +153,10 @@ function visit(node, name, scope) {
* @param {NodePath} param0
* @param {Boolean} localBinding whether a name could shadow a self-reference (e.g. converting arrow function)
*/
export default function ({ node, parent, scope, id }, localBinding = false) {
export default function (
{ node, parent, scope, id }: any,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ node, parent, scope, id }: any,
{ node, parent, scope, id }: { node: any, parent: any, scope: any, id: any },

It's still full of anys, but at least it gives basic safety against typos and autocompletion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done,
Ideally it should use NodePath, but there is an issue about circular dependency to use it

@zxbodya zxbodya force-pushed the ts-migration/babel-helper-function-name branch from a64e701 to 1e1868f Compare December 15, 2020 18:13
@nicolo-ribaudo nicolo-ribaudo merged commit 4f1df9a into babel:main Dec 15, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the ts-migration/babel-helper-function-name branch December 15, 2020 22:20
@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 Mar 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Flow -> TS Tracking repository migration from Flow to TS outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants