Giter VIP home page Giter VIP logo

Comments (5)

vicb avatar vicb commented on April 17, 2024

What about re-using the existing ArrowFunctionTransformer ?

from angular.

vojtajina avatar vojtajina commented on April 17, 2024

@vicb ArrowFunctionTransformer transforms () {} into a regular function like var _this = this; function() {};

I think the js2dart transpiler should NOT include ArrowFunctionTransformer - keep the arrow functions and dart writer will output them as () {} instead of () => {}.

from angular.

vicb avatar vicb commented on April 17, 2024

@vojtajina I think we are both right to some extent - being positive :)

We should not include the original ArrowFunctionTransformer as it renames this which is not required for Dart. However Dart => functions could only be composed of a single statement and always have an implicit return.

I think the way to go is to create a new transformer [based on ArrowFunctionTransformer] that only transform the concise body.

from angular.

vicb avatar vicb commented on April 17, 2024

More details:
In ES6, arrow functions have an implicit return if they are not defined with a function body:

// body -> no implicit return
var square = (x) => {
  return x * x;
};
// no fn body -> implicit return
var square2 = x => x * x;
var objectify = x => ({ value: x });

Whereas arrow functions in Dart are composed of a single statement & always have an implicit return.

What should be done:

  • Fat arrow functions in JS need to be transpiled to () {} in Dart. (original issue),
  • convertConciseBody

from angular.

angular-automatic-lock-bot avatar angular-automatic-lock-bot commented on April 17, 2024

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.