You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Seeing the same. In fact, anything with int is failing for me. Using number though with parameter annotations works, but not for field annotations. For example, this works fine:
classMyClass{constructor(xArg:number,yArg:number){this.x=xArg;this.y=yArg;}}varmyClass=newMyClass(1,2);console.log(myClass);varmyClass2=newMyClass("test","test");// this will fail in the console (as expected)
It specifies that the transpiler can generate the constructor. But it does not say if the constructor will assign values. In the example provided by @mhevery field variables are assigned to null.
So, I agree with you on the fact it does not generate constructor, but anyway according to this document atScript will not auto-assign your fields. So, you'll have to write a constructor.
It specifies that the transpiler can generate the constructor. But it
does not say if the constructor will assign values. In the example provided
by @mheveryhttps://github.com/mhevery field variables are assigned to
null.
But when I transpile the code into es6 using traceur, there is no
constructor :
class Point {
get x() {
return this.$__0;
}
set x(value) {
this.$__0 = value;
}
get y() {
return this.$__1;
}
set y(value) {
this.$__1 = value;
}
}Object.defineProperty(Object.getOwnPropertyDescriptor(Point.prototype, "x").set, "parameters", {get: function() {
return [[int]];
}});Object.defineProperty(Object.getOwnPropertyDescriptor(Point.prototype, "y").set, "parameters", {get: function() {
return [[int]];
}});
So, I agree with you on the fact it does not generate constructor, but
anyway according to this document atScript will not auto-assign your
fields. So, you'll have to write a constructor.
—
Reply to this email directly or view it on GitHub #7 (comment)
.
Activity
smaye81 commentedon Nov 6, 2014
Seeing the same. In fact, anything with
intis failing for me. Usingnumberthough with parameter annotations works, but not for field annotations. For example, this works fine:But this doesn't:
mlb6 commentedon Nov 18, 2014
I solved the problem on my side by adding this to the config.json : "memberVariables":true
I guessed it by looking at this line of the traceur code: https://github.com/google/traceur-compiler/blob/master/src/Options.js#L143
smaye81 commentedon Nov 18, 2014
Interesting. I can get it to compile by doing that also. I can also define a class like above with:
But if I try to instantiate it like so:
I see this in my console:
And this is my config:
mlb6 commentedon Nov 20, 2014
You get this error because you forgot to write a constructor :
smaye81 commentedon Nov 20, 2014
Shouldn't the transpiler auto-generate the constructor for me? Take a look at the AtScript primer by @mhevery
https://docs.google.com/document/d/11YUzC-1d0V1-Q3V0fQ7KSit97HnZoKVygDxpWzEYW0U/mobilebasic?viewopt=127
Look at the Field Annotations section, specifically this line:
By specifying the fields in this way, the transpiler can generate the constructor which then pre-creates the fields.
Add memberVariables traceur option to fix issue angular#7
mlb6 commentedon Nov 20, 2014
It specifies that the transpiler can generate the constructor. But it does not say if the constructor will assign values. In the example provided by @mhevery field variables are assigned to null.
But when I transpile the code into es6 using traceur, there is no constructor :
So, I agree with you on the fact it does not generate constructor, but anyway according to this document atScript will not auto-assign your fields. So, you'll have to write a constructor.
mhevery commentedon Nov 20, 2014
work in progress.
On Thu Nov 20 2014 at 1:39:03 PM Martin Le Bas notifications@github.com
wrote: