goal
I would like to write a javascript library (framework), but you need OOP and mixins.
Sent to typescript, but it does not support mixins (the manual says that it is, but the compiler / specs have nothing to do with mixin).
Typescript
The following code is provided in typescript:
class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } }
Compiles:
var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prototype.greet = function () { return "Hello, " + this.greeting; }; return Greeter; })();
Then, customers can simply call:
var greeter = new Greeter("world");
Dart
Can a dart do something like this? Can anyone show how?
The main goal is that the javascript generated is readable, preferably with all the other darts in another script.
I saw this question and this answer , but none of them gives a readable JS file, as in the typescript example above.
source share