Skip to content
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

Class marked as unused when used in a static block #1259

Open
nicolo-ribaudo opened this issue Mar 3, 2024 · 0 comments
Open

Class marked as unused when used in a static block #1259

nicolo-ribaudo opened this issue Mar 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Mar 3, 2024

let BluethootDevice_create;
class BluethootDevice {
  #id!: string;

  static #allowConstruct = false;

  private constructor() {
    if (!BluethootDevice.#allowConstruct) {
      throw new Error("You cannot instantiate this class directly");
    }
  }

  static {
    BluethootDevice_create = (id: string) => {
      BluethootDevice.#allowConstruct = true;
      const device = new BluethootDevice();
      BluethootDevice.#allowConstruct = false;
      device.#id = id;
      return device;
    };
  }

  get id() {
    return this.#id;
  }
}

BluethootDevice_create("aa");

deno_lint marks BluethootDevice as unused and tells me to rename it to _BluethootDevice, but it's used by the BluethootDevice_create.

@dsherret dsherret added the bug Something isn't working label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants