0

I created a Lit component, following the instructions on their website, and when i use it as a typescript file i get this error: 'Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "video/mp2t". Strict MIME type checking is enforced for module scripts per HTML spec.' If i use it as a .js file its working. Why so? HTML:

  <!DOCTYPE html>
<head>
  <script type="module" src="./simple-greeting.js"></script>
</head>
<body>
  <simple-greeting name="World"></simple-greeting>
</body>

TS:

import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
  static styles = css`p { color: blue }`;

  @property()
  name = 'Somebody';

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}

I installed @web/dev-server and @webcomponents/webcomponentsjs,

  • If JavaScript works for you, it may be an issue with your [TypeScript configuration](https://lit.dev/docs/components/decorators/#decorators-typescript)? Are you running `tsc` to generate a JavaScript file from your TypeScript, and then are you referencing this built JavaScript file as `./simple-greeting.js`? What is the name of your TypeScript file? – YouCodeThings Dec 06 '22 at 17:19

0 Answers0