Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.7K
Visualizações
A class member cannot have the 'const' keyword

I am using ts and keep getting stuck when trying to create const that can be used by just changing a simple element.keep getting A class member cannot have the 'const' keyword

code:

const LINKS = {
  Summary: 82,
  Telephone: 83
};

itemLocator(ItemId): Locator {
  const navItemSelector = `'div[id="${ItemId}"]'`
  return page.locator(itemLocator)
}

tired doing const function, and const

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The duplicate answers that suggest using readonly in the comments are valid for simple properties.

In your case, because you're using an object property, you need an additional const assertion:

class Test {
  readonly LINKS = {
    Summary: 82,
    Telephone: 83
  } as const;
}

const test = new Test();
test.LINKS = {}; // error
test.LINKS.Summary = 83; // error

Without the const assertion, you would still be able to change the value Summary and Telephone values inside LINKS.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda