question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Class constructor LitElement cannot be invoked without 'new'

See original GitHub issue

I’m trying out Lit Element in a vanilla Angular 6 project and running into Uncaught TypeError: Class constructor LitElement cannot be invoked without 'new' when trying out the hello world lit element example. This commit shows how I added webcomponentjs / litelement packages, allow custom schema in angular, declare the my-element LitElement example, and then use that element in the app. That commit was made right after running the ng new command.

screen shot 2018-05-11 at 3 33 16 pm

If you want to poke at it, run the following commands…

git clone https://github.com/rjsteinert/angular-with-lit-element.git
cd angular-with-list-element
npm install
npm start

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:55 (20 by maintainers)

github_iconTop GitHub Comments

13reactions
daniel-nagycommented, Feb 1, 2019

To anyone else that ends up here, lit-element is distributed as es2015 so you must transpile it to es5 as part of your build process. If you’re using Webpack add the following to your JavaScript rule:

{
  include: [
    // These packages are distributed as es2015 modules, therefore they need
    // to be transpiled to es5.
    /node_modules(?:\/|\\)lit-element|lit-html/
  ]
}
9reactions
dkundelcommented, Jun 12, 2018

Hey @rjsteinert,

do you need it to be downtranspiled to ES5? I changed my tsconfig.json to target ES2015 and then using the polyfill without the adapter works. You can see an example here: https://github.com/dkundel/vote-my-talk/commit/8b7f29a2993076b05582914b594b9500d67d919b

Cheeers, Dominik

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class constructor LitElement cannot be invoked without 'new ...
I'm trying out Lit Element in a vanilla Angular 6 project and running into Uncaught TypeError: Class constructor LitElement cannot be ...
Read more >
How to fix `Class constructor LitElement cannot be invoked ...
After struggling with it for a while, it seems parcel (as of v1.12.3) has an issue where it doesn't consider the browserslist unless ......
Read more >
TypeError: Class constructor HTMLElement cannot be invoked ...
This error occurs while running a unit test. The component that you are running has probably some 3rd party code which contains class...
Read more >
Class constructor cannot be invoked without 'new' in TS
The "Class constructor cannot be invoked without new" error occurs when the target property in tsconfig.json is set to lower than es6 or...
Read more >
class constructor cannot be invoked without 'new'
Class constructor LitElement cannot be invoked without 'new' Class constructor PolymerElement cannot be invoked without 'new' 7.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found