Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.05k stars 2.01k forks source link

_attachDom type signature is too restrictive #5665

Open e111077 opened 4 years ago

e111077 commented 4 years ago

Description

_attachDom's docs say that it can be overriden to support any type of node that is not just only a shadow root. The return types though seem to be ShadowRoot | null which means that you cannot return this as an acceptable root.

https://github.com/Polymer/polymer/blob/76c71e186ecc605294c3575dd31ac7983a8b3ae3/lib/mixins/element-mixin.js#L734

https://github.com/Polymer/polymer/blob/36fb37e9d37195065e035d8c82f57789d95e670b/lib/mixins/element-mixin.d.ts#L221

Steps to Reproduce

  1. override _attachDom
  2. place the snippet below
  3. attempt to compile with closure or TS
_attachDom(dom) {
  this.appendChild(dom);
  return this;
}

Expected Results

no compilation error

Actual Results

compilation error

Browsers Affected

N/A

Versions

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.