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

312
Views
TypeScript: Cannot access a object by variable key

Here my code looks like:


export const EMOJI_NAME_KEY = "n";
export const EMOJI_UNICODE_KEY = "u";


export interface Emoji {
  [EMOJI_NAME_KEY]: string[];
  [EMOJI_UNICODE_KEY]: string;
}

const emoji: Emoji = {
   [EMOJI_NAME_KEY]: 'thumb',
   [EMOJI_UNICODE_KEY]: 'some_unicode_key'
}

Now whenever I try to access a value from Emoji type, I'm getting an error. For example:

console.log(emoji[EMOJI_NAME_KEY]) // returns error in the terminal like below

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Emoji'. No index signature with a parameter of type 'string' was found on type 'Emoji'

about 4 years ago · Juan Pablo Isaza
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!