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

177
Visualizações
Angular unit testing the localstorage, Error ts(7053)

beforeEach (() => { ...

   let store = {};
  const mockSessionStorage = {
  getItem: (key: string): string => key in store ? store[key] : null,
  setItem: (key: string, value: string) => store[key] = `${value}`,
  removeItem: (key: string) => delete store[key],
  clear: () => store = {}
};
...

and i get the Error Message The element implicitly has a type "any" because the expression of type "string" cannot be used for the index type "{}". No index signature with a parameter of type "string" was found for type "{}".ts(7053)

Also I'm new to typscript and don't know if it's because of the error message or if I'm doing something else wrong I would be happy if someone could take a quick look.

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

0

Try typing your store variable.

Something like this:

let store:{ [key: string]: string } = {};
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