Skip to content
This repository was archived by the owner on Oct 26, 2021. It is now read-only.

Reenable the TypeScript tests with updated compiler output #151

Merged
merged 4 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom-elements.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion custom-elements.min.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/Patch/HTMLElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export default function(internals) {
}

HTMLElement.prototype = Native.HTMLElement.prototype;
// Safari 9 has `writable: false` on the propertyDescriptor
// Make it writable so that TypeScript can patch up the
// constructor in the ES5 compiled code.
Object.defineProperty(HTMLElement.prototype, 'constructor', {
writable: true,
configurable: true,
enumerable: false,
value: HTMLElement
});

return HTMLElement;
})();
Expand Down
51 changes: 33 additions & 18 deletions tests/js/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

/*
Original TypeScript source code used in this test suite:

class XTypescript extends HTMLElement {}
class XTypescript2 extends HTMLElement {}

*/
suite('TypeScript ES5 Output', function() {

customElements.enableFlush = true;

// Fails because the XTypescript constructor does not return the result of
// the super call. See: https://github.com/Microsoft/TypeScript/issues/7574
test.skip('TypeScript generated ES5 works via new()', function() {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var XTypescript = (function (_super) {
test('TypeScript generated ES5 works via new()', function() {
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var XTypescript = /** @class */ (function (_super) {
__extends(XTypescript, _super);
function XTypescript() {
_super.call(this);
return _super !== null && _super.apply(this, arguments) || this;
}
return XTypescript;
}(HTMLElement));
Expand All @@ -38,16 +48,21 @@ suite('TypeScript ES5 Output', function() {
assert.instanceOf(e, XTypescript);
});

test.skip('TypeScript generated ES5 works via createElement', function() {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var XTypescript2 = (function (_super) {
test('TypeScript generated ES5 works via createElement', function() {
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var XTypescript2 = /** @class */ (function (_super) {
__extends(XTypescript2, _super);
function XTypescript2() {
_super.call(this);
return _super !== null && _super.apply(this, arguments) || this;
}
return XTypescript2;
}(HTMLElement));
Expand Down