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
This was originally going to be a bug report for JSON exports using the constructor argument names instead of class member names, but I realized how much work that would be to have the compiler use the class member names.
The compiler's emitters work on a statement by statement basis, so at emitting time, a constructor function written like this:
When the emitter is doing the export, the statement: new Person("John", "Smith") where you would expect {firstName: "John", lastName: "Smith"}, you actually get {p_firstName: "John", p_lastName: "Smith"}.
You'd have to have an interpreter to know that p_firstName correlates to firstName.
Additionally, what if inside the constructor it was: this.firstName = p_firstName.charAt(0).toUpperCase() + p_firstName.substr(1).toLowerCase()? I know that's a little convoluted, but there's no way you'd be able to export what you'd expect to export via JSON.
Because of that, if you have a class that has the metadata set to JSON mode and no export, I think the compiler should throw a warning or even an error if there's anything other than public property definitions.
The text was updated successfully, but these errors were encountered:
This was originally going to be a bug report for JSON exports using the constructor argument names instead of class member names, but I realized how much work that would be to have the compiler use the class member names.
The compiler's emitters work on a statement by statement basis, so at emitting time, a constructor function written like this:
When the emitter is doing the export, the statement: new Person("John", "Smith") where you would expect {firstName: "John", lastName: "Smith"}, you actually get {p_firstName: "John", p_lastName: "Smith"}.
You'd have to have an interpreter to know that p_firstName correlates to firstName.
Additionally, what if inside the constructor it was: this.firstName = p_firstName.charAt(0).toUpperCase() + p_firstName.substr(1).toLowerCase()? I know that's a little convoluted, but there's no way you'd be able to export what you'd expect to export via JSON.
Because of that, if you have a class that has the metadata set to JSON mode and no export, I think the compiler should throw a warning or even an error if there's anything other than public property definitions.
The text was updated successfully, but these errors were encountered: