Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fireflysemantics opened this issue Sep 4, 2024 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@fireflysemantics
Copy link

🔎 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

@MartinJohns
Copy link
Contributor

Duplicate of #20595. You can't use DOM and WebWorker at the same time.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Sep 5, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants