Skip to content

Adding "WebWorker" to the lib compiler options causes compilation to fail? #59850

Closed as not planned
@fireflysemantics

Description

@fireflysemantics

🔎 Search Terms

adding "WebWorker" to typescript

🕗 Version & Regression Information

  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

/**
 *  @category WebComponent
 *
 * Hello World Web Component
 * that renders a greeting.
 */
export class HelloWorldComponent extends HTMLElement {
    static get observedAttributes() {
      return ['name'];
    }
  
    /**
     * The name to greet
     * @defaultValue World
     */
    name: string | null = 'World';
    something!: string;
    /**
     * Initializes the name property to `World`.
     */
    constructor() {
      super();
      //    this.name = 'World';
    }
  
    /**
     * Sets the component inner
     * html to the greeting.
     */
    connectedCallback() {
      this.textContent = `Hello ${this.name}!`;
    }
  
    //========================================
    // attribute change callback
    //========================================
    attributeChangedCallback(
      property: keyof HelloWorldComponent,
      oldValue: string | null,
      newValue: string | null
    ) {
      if (oldValue === newValue) return;
      switch (property) {
        case 'name':
          this.name = newValue;
          break;
        default:
          throw new Error(`Unhandled attribute: ${property}`);
      }
    }
  }
  customElements.define('hello-world', HelloWorldComponent);

🙁 Actual behavior

Please see this Stackoverflow issue for the full description.
https://stackoverflow.com/questions/78949923/creating-a-typescript-project-with-support-for-web-workers

The typescript shared compiles fine. When "WebWorker" is added to the lib compiler options, compilation starts generating errors.

🙂 Expected behavior

It should still compile fine.

Additional information about the issue

Please see this Stackoverflow issue for the full description.
https://stackoverflow.com/questions/78949923/creating-a-typescript-project-with-support-for-web-workers

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions