Skip to content

Commit 3d27b4e

Browse files
committed
Fix closure compiler error
I'm trying to fix some bugs in the Closure compiler template type checker. The fix has revealed a type error in shadydom, which this PR attempts to fix. With the fix, the following error occurs: ``` shadydom/src/patch-events.js:286:53: ERROR - [JSC_TYPE_MISMATCH] actual parameter 3 of Object.defineProperty does not match formal parameter found : ObjectPropertyDescriptor<Event> required: ObjectPropertyDescriptor<(Event|{ composed: ?, composedPath: function(this:Event): ?, relatedTarget: ?, stopImmediatePropagation: function(this:Event): undefined, stopPropagation: function(this:Event): undefined, target: ? })> 286| /** @type {!ObjectPropertyDescriptor<!Event>} */ ({ ^^ 287| /** ^^^^^^^^^ ... 296| configurable: true, ^^^^^^^^^^^^^^^^^^^^^^^^^ 297| }) ^^^^^^ ``` This error is correct because EventPatches is an object literal, which can never be an Event because Event is a nominal type in Closure. I think this change should be OK and will unblock Closure compiler fixes.
1 parent f91938f commit 3d27b4e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/shadydom/src/patch-events.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,14 @@ if (eventPhaseDescriptor) {
283283
Object.defineProperty(
284284
EventPatches,
285285
'eventPhase',
286-
/** @type {!ObjectPropertyDescriptor<!Event>} */ ({
286+
/** @type {!ObjectPropertyDescriptor<!{
287+
composed: ?,
288+
composedPath: function(this:Event): ?,
289+
relatedTarget: ?,
290+
stopImmediatePropagation: function(this:Event): undefined,
291+
stopPropagation: function(this:Event): undefined,
292+
target: ?
293+
}>} */ ({
287294
/**
288295
* @this {Event}
289296
*/

0 commit comments

Comments
 (0)