Godfrey Chan
cc2dc3acb0
Emit more efficient/concise "empty" ES6 ctor
...
When there are property assignments in a the class body of an inheriting
class, tsc current emit the following compilation:
```ts
class Foo extends Bar {
public foo = 1;
}
```
```js
class Foo extends Bar {
constructor(…args) {
super(…args);
this.foo = 1;
}
}
```
This introduces an unneeded local variable and might force a reification
of the `arguments` object (or otherwise reify the arguments into an
array).
This is particularly bad when that output is fed into another transpiler
like Babel. In Babel, you get something like this today:
```js
var Foo = (function (_Bar) {
_inherits(Foo, _Bar);
function Foo() {
_classCallCheck(this, Foo);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_Bar.call.apply(_Bar, [this].concat(args));
this.foo = 1;
}
return Foo;
})(Bar);
```
This causes a lot of needless work/allocations and some very strange
code (`.call.apply` o_0).
Admittedly, this is not strictly tsc’s problem; it could have done a
deeper analysis of the code and optimized out the extra dance. However,
tsc could also have emitted this simpler, more concise and semantically
equivalent code in the first place:
```js
class Foo extends Bar {
constructor() {
super(…arguments);
this.foo = 1;
}
}
```
Which compiles into the following in Babel:
```js
var Foo = (function (_Bar) {
_inherits(Foo, _Bar);
function Foo() {
_classCallCheck(this, Foo);
_Bar.apply(this, arguments);
this.foo = 1;
}
return Foo;
})(Bar);
```
Which is well-optimized (today) in most engines and much less confusing
to read.
As far as I can tell, the proposed compilation has exactly the same
semantics as before.
Fixes #10175
2016-08-06 23:24:44 -07:00
..
2016-07-27 12:05:45 -07:00
2016-07-27 12:05:45 -07:00
2016-07-27 12:05:45 -07:00
2016-07-27 12:05:45 -07:00
2016-07-27 12:05:45 -07:00
2016-07-18 17:18:35 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-08-02 12:34:23 -07:00
2016-07-30 08:17:46 -07:00
2016-07-30 08:17:46 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-08-01 09:50:08 -07:00
2016-08-01 09:50:08 -07:00
2016-08-01 09:50:08 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 17:38:25 -07:00
2016-07-22 17:38:25 -07:00
2016-07-22 13:38:45 -07:00
2016-07-22 13:38:45 -07:00
2016-07-18 17:31:48 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-08-06 23:24:44 -07:00
2016-07-26 13:28:04 -07:00
2016-07-26 13:28:04 -07:00
2016-07-26 13:28:04 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-29 08:34:14 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:33:36 -07:00
2016-07-27 15:33:36 -07:00
2016-07-27 15:33:36 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 13:16:45 -07:00
2016-07-18 13:16:45 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-06 23:24:44 -07:00
2016-07-24 07:28:11 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-27 17:10:14 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 16:56:33 -07:00
2016-08-03 09:01:40 -07:00
2016-08-03 09:01:40 -07:00
2016-08-03 09:01:40 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 13:16:45 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 16:56:33 -07:00
2016-07-27 15:36:54 -07:00
2016-07-27 15:36:54 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 16:56:33 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-22 16:56:33 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-08-01 07:04:54 -07:00
2016-08-01 07:04:54 -07:00
2016-08-01 07:04:54 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 15:41:52 -07:00
2016-07-22 15:41:52 -07:00
2016-07-22 15:41:52 -07:00
2016-07-22 15:41:52 -07:00
2016-07-22 15:41:52 -07:00
2016-07-22 15:41:52 -07:00
2016-08-01 09:50:17 -07:00
2016-08-01 09:50:17 -07:00
2016-07-19 15:16:27 -07:00
2016-07-19 15:16:27 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-23 15:05:36 +09:00
2016-07-23 15:05:36 +09:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-27 15:36:54 -07:00
2016-08-02 11:06:18 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-08-03 10:05:49 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-01 09:50:17 -07:00
2016-08-01 09:50:17 -07:00
2016-07-18 13:16:45 -07:00
2016-07-29 08:34:14 -07:00
2016-07-29 08:34:14 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-24 07:28:11 -07:00
2016-07-24 07:28:11 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-04 14:13:07 -07:00
2016-08-04 14:13:07 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-03 10:05:49 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-03 10:05:49 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-03 10:05:49 -07:00
2016-08-03 10:05:49 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-08-04 07:43:54 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-08-05 10:12:01 -07:00
2016-07-27 15:36:54 -07:00
2016-08-02 11:06:18 -07:00
2016-07-18 17:31:48 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:18:35 -07:00
2016-07-18 17:31:48 -07:00
2016-07-22 16:56:33 -07:00