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

319
Visualizações
what is & in typescript and javascript?

i saw this in the someone else's code. (this is props of react component.) i know & is AND logical operater. i think & has another meaning in this code. when i use center = {{latitude: number,longitude: number},{zoom: 2, tilt: 2,}} it is not worked and i know not match vaild format with typescript error.

  1. what is & mean in this?
  2. how to vaild object format in center props(i use react.)?
export interface Coord {
    latitude: number;
    longitude: number;
}
center?: Coord & { zoom?: number; tilt?: number; bearing?: number };
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The & is Intersection Type

Basically, it lets you combine types

like the final object center should contain all those keys mentioned in

 { zoom?: number; tilt?: number; bearing?: number, latitude, longitude };

official doc : https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types

The reason that this

center = {{latitude: number,longitude: number},{zoom: 2, tilt: 2,}}

didn't work is that , first its not a valid object , second all the keys mentioned ( { zoom?: number; tilt?: number; bearing?: number, latitude, longitude } ) should be present in the object

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