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

226
Visualizações
Parameter 'array' implicitly has 'any' type. What does this mean?
var milkResponses: string[] = ["I like milk", "mmmm"];
function randomArrayShuffle(array) {
    var currentIndex = array.length, temporaryValue, randomIndex;
    while (0 !== currentIndex) {
      randomIndex = Math.floor(Math.random() * currentIndex);
      currentIndex -= 1;
      temporaryValue = array[currentIndex];
      array[currentIndex] = array[randomIndex];
      array[randomIndex] = temporaryValue;
    }
    return array;
  }

What I want to do is randomize a string array such as milkResponses, but the array parameter has an error saying that Parameter 'array' implicitly has an 'any' type. I'm not sure what it means. I think its because I made the array wrong?

Appreciate the help

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

0

If there's nothing that either explicitly sets the type of something in TypeScript, or a reliable way for TypeScript to infer that type (e.g. by creating a variable and immediately setting it to a value), then TypeScript will implicitly give it the type any. By default, TypeScript is configured to not allow code containing any implicit any to compile, which is why you're seeing this error.

Because it's a function argument without a default value, you'll want to specify its value explicitly. It looks like your function can operate on arrays that contain anything, so you probably want to use function randomArrayShuffle(array: any[]) {

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