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

330
Visualizações
Is there any better way to IntrinsicAttributes & TYPE in Typescript

This code is works good.

<AuctionCardGenerator auction={auction} />;
interface auctionType {
    auction: randomAuctionType;
}

const AuctionCardGenerator = ({ auction }: auctionType) => {
...
}

and randomAuctionType is looks this.

interface randomAuctionType {
    id: number;
    title: string;
    artist: {
        id: number;
        name: string;
        nickname: string;
    };
    type: string;
    price: string;
    description: string;
    status: AUCTION_STATE;
    nftToken?: string;
    imgSrc: string;
}

But I think that declaring auctionType just for this code isn't efficient. So I want to use just like bellow.

const AuctionCardGenerator = (auction: randomAuctionType) => {

But this code has error message like this enter image description here

So, Is there any simple way to avoid this problem in typescript?

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

0

If you don't want to declare a standalone interface (although there's nothing wrong with it - it doesn't cost you anything!), you can use an inline type literal instead:

const AuctionCardGenerator = ({ auction }: { auction: randomAuctionType; }) => {
...
}
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