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

193
Visualizações
Typescript thinks boolean check is a string

I'm running into an issue when I'm trying to check if all of the properties in an object are populated and assigning the result to a boolean. This is the code:

this.isAddressValid = address.street && address.city && address.state && address.zip && address.country;

When I leave it like this, I get an error that states: Type 'string' is not assignable to type 'boolean'

But it seems to work if I add a simple conditional to the end:

this.isAddressValid = address.street && address.city && address.state && address.zip && address.country ? true : false;

I'm wondering why this is happening. Shouldn't the statement become a boolean by using the && operator? Why do I need to add the conditional for this to work?

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