Giter Club home page Giter Club logo

Comments (14)

vicb avatar vicb commented on March 29, 2024

wrt TypeScript:

  1. fields can be initialized where they're defined
  2. fields are not initialized iff an initializer is present (not implicitly set to null)

from angular.

arv avatar arv commented on March 29, 2024

We should add support for these in Traceur. TS supports these and the goal was to use TS type syntax inside Traceur.

from angular.

vicb avatar vicb commented on March 29, 2024

During the discussion with @arv, we rise an "issue" with initializers: while those are supported in Dart, the intialization would need to happen at ctor time in JS.

Let's say you have this code:

class Parent {
  name:string='Joe';
}

class Child extends Parent {
  age:int;
  constructor(age:int) {
    this.age = age;
    //super(); - this would be needed to have this code work properly
  }
}

Parent.name would not be initialized when you instantiate a Child class because super() is not called. However it seems weird to call super() when no ctor is defined on Parent - it would only be generated at compile time to initialize the fields.

May be the best is to drop the support for initializers for now ?

from angular.

vicb avatar vicb commented on March 29, 2024

depends on #69

from angular.

arv avatar arv commented on March 29, 2024

ES6 generates a constructor if there is an extends expression but no constructor. It uses constructor(...args) { super(...args); }. So if you are generating a constructor you need to ensure that super is called.

For earlier version of the class proposal we used a two phase init. One phase to initialize all properties defined outside the constructor and a second phase to call the constructor.

If a sub class fails to call super they are doing it wrong. You could make that an error in your linter for example.

from angular.

vicb avatar vicb commented on March 29, 2024

ES6 generates a constructor if there is an extends expression but no constructor. It uses constructor(...args) { super(...args); }.

Interesting, thanks - I had deducted it from the code but I had to verify in the spec. Not needed anymore. (BTW Dart does not inherit ctor by default, we have to update the transpiler).

I'll create a ticket on Traceur with what I have in mind and opened questions so that we wan discuss there before I submit the impl in a PR.

from angular.

naomiblack avatar naomiblack commented on March 29, 2024

@vojtajina can you sync with @vicb on this and sync on status. We want to get to a point where all @field annotations are removed from source base.

from angular.

naomiblack avatar naomiblack commented on March 29, 2024

@vicb can you update on status, and an estimate of how much left to complete...?

from angular.

vicb avatar vicb commented on March 29, 2024

@naomiblack Traceur plans to have some support for that. I'll discuss with @arv to see if I can submit a PR there. I hope to be able to give an estimate by eow.

from angular.

vicb avatar vicb commented on March 29, 2024

The PR on traceur is working (google/traceur-compiler#1417). I expect to have to do some updates after review but it should be available in the following days. Then I can concentrate on generate the Dart code for this.

from angular.

naomiblack avatar naomiblack commented on March 29, 2024

@vicb @vojtajina is this one closed or still pending some action...?

from angular.

vicb avatar vicb commented on March 29, 2024

The PR has been merged to traceur at the end of last week. I need to add dart support to this repo when I'm back from vacations. Please leave open.

Le 4 novembre 2014 14:25:22 GMT+09:00, Naomi Black [email protected] a écrit :

@vicb is this one closed or still pending some action...?


Reply to this email directly or view it on GitHub:
#66 (comment)

from angular.

vojtajina avatar vojtajina commented on March 29, 2024

#167

from angular.

angular-automatic-lock-bot avatar angular-automatic-lock-bot commented on March 29, 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.