Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeScript and upstream internal changes. #525

Merged
merged 11 commits into from
Oct 4, 2022
1,488 changes: 907 additions & 581 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
},
"devDependencies": {
"@gulp-sourcemaps/sources-content": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"babel-core": "^6.26.3",
"chokidar-cli": "^2.1.0",
"del": "^3.0.0",
"eslint": "^7.18.0",
"eslint-plugin-html": "^6.1.1",
"eslint": "^8.23.1",
"eslint-plugin-html": "^7.1.0",
"google-closure-compiler": "^20210202.0.0",
"gulp": "^4.0.0",
"gulp-babel": "^7.0.1",
Expand All @@ -44,7 +44,7 @@
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-license": "^0.8.1",
"typescript": "^4.0.3",
"typescript": "^4.8.3",
"wct-browser-legacy": "^1.0.2",
"web-component-tester": "^6.9.2"
},
Expand Down
24 changes: 12 additions & 12 deletions packages/custom-elements/ts_src/CustomElementInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ export default class CustomElementInternals {
if (definition) {
this._upgradeAnElement(element, definition);
}
} catch (e) {
this.reportTheException(e);
} catch (e: unknown) {
this.reportTheException(e as Error);
bicknellr marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -340,8 +340,8 @@ export default class CustomElementInternals {
if (definition.connectedCallback) {
try {
definition.connectedCallback.call(element);
} catch (e) {
this.reportTheException(e);
} catch (e: unknown) {
this.reportTheException(e as Error);
}
}
}
Expand All @@ -351,8 +351,8 @@ export default class CustomElementInternals {
if (definition.disconnectedCallback) {
try {
definition.disconnectedCallback.call(element);
} catch (e) {
this.reportTheException(e);
} catch (e: unknown) {
this.reportTheException(e as Error);
}
}
}
Expand All @@ -377,8 +377,8 @@ export default class CustomElementInternals {
newValue,
namespace
);
} catch (e) {
this.reportTheException(e);
} catch (e: unknown) {
this.reportTheException(e as Error);
}
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@ export default class CustomElementInternals {
return;
}

return (registry as CustomElementRegistry).internal_localNameToDefinition(
return ((registry as unknown) as CustomElementRegistry).internal_localNameToDefinition(
localName
);
}
Expand All @@ -436,7 +436,7 @@ export default class CustomElementInternals {
// Only create custom elements if the document is associated with a
// registry.
if (registry && (namespace === null || namespace === NS_HTML)) {
const definition = (registry as CustomElementRegistry).internal_localNameToDefinition(
const definition = ((registry as unknown) as CustomElementRegistry).internal_localNameToDefinition(
localName
);
if (definition) {
Expand Down Expand Up @@ -507,8 +507,8 @@ export default class CustomElementInternals {
}

return result;
} catch (e) {
this.reportTheException(e);
} catch (e: unknown) {
this.reportTheException(e as Error);

// When construction fails, a new HTMLUnknownElement is produced.
// However, there's no direct way to create one, so we create a
Expand Down
4 changes: 2 additions & 2 deletions packages/custom-elements/ts_src/CustomElementRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ export default class CustomElementRegistry {
this._localNameToConstructorGetter.delete(localName);
try {
return this.internal_reifyDefinition(localName, constructorGetter());
} catch (e) {
this._internals.reportTheException(e);
} catch (e: unknown) {
this._internals.reportTheException(e as Error);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/custom-elements/ts_src/Patch/HTMLElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function (internals: CustomElementInternals) {

// Always look up the definition from the global registry.
const registry = document.__CE_registry!;
const definition = (registry as CustomElementRegistry).internal_constructorToDefinition(
const definition = ((registry as unknown) as CustomElementRegistry).internal_constructorToDefinition(
constructor
);
if (!definition) {
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-elements/ts_src/custom-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function installPolyfill() {
const customElements = new CustomElementRegistry(internals);

// The main document is associated with the global registry.
document.__CE_registry = customElements;
(document.__CE_registry as unknown) = customElements;
bicknellr marked this conversation as resolved.
Show resolved Hide resolved

Object.defineProperty(window, 'customElements', {
configurable: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/formdata-event/ts_src/environment/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

export const constructor = window.Event;
export const constructor: typeof Event = window.Event;
bicknellr marked this conversation as resolved.
Show resolved Hide resolved

export const prototype = constructor.prototype;

Expand Down
6 changes: 3 additions & 3 deletions packages/formdata-event/ts_src/wrappers/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const getEventPropagationImmediatelyStopped = (e: Event) => {
// const s = new SpecialEvent("type");
// console.assert(s instanceof SpecialEvent); // fails in Safari 13.1
// ```
export const Event: typeof window.Event = (function Event(
export const Event: typeof EventConstructor = (function Event(
this: Event,
type: string,
eventInit: EventInit = {}
) {
): Event {
let _this;
// When running in a browser where Event isn't constructible (e.g. IE11) this
// throws and we fall back to the old `createEvent` API.
Expand All @@ -53,7 +53,7 @@ export const Event: typeof window.Event = (function Event(
}
Object.setPrototypeOf(_this, Object.getPrototypeOf(this));
return _this;
} as Function) as typeof window.Event;
} as unknown) as typeof EventConstructor;

prepareWrapper(Event, EventConstructor, EventPrototype);

Expand Down
2 changes: 1 addition & 1 deletion packages/webcomponentsjs/ts_src/platform/custom-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (!window.Event || (isIE && typeof window.Event !== 'function')) {

// CustomEvent constructor shim
if (!window.CustomEvent || (isIE && typeof window.CustomEvent !== 'function')) {
window['CustomEvent'] = ((<T extends unknown>(
window['CustomEvent'] = ((<T>(
inType: string,
params?: CustomEventInit<T>
) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/webcomponentsjs/ts_src/platform/es6-misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
export {};

if (!Array.from) {
Array.from = <T extends unknown>(object: ArrayLike<T>): Array<T> => {
Array.from = <T>(object: ArrayLike<T>): Array<T> => {
return [].slice.call(object);
};
}
Expand Down