Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.6K
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!