Search code examples
typescriptweb-component

Does typescript support web components?


I been reading up on web components and thought they are amazing so I jumped into my preferred work space(vs code, typescript 2.4.2) but it seems it doesn't support web components, or they are partly supported? the HTMLElement type definition contains a read-only field labeled: 'shadow root" but this is null by default and the HTMLElement type def doesn't have the method: create shadow root() so I'm not sure if I'm doing this wrong or something if I am could someone point me in the right direction?


Solution

  • Typescript supports web components. Method createShadowRoot is not in the typings because it was deprecated and removed from actual spec. You can read more about this method on MDN. You should use attachShadow method instead.