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

170
Visualizações
Issue with importing entire file such as parameters.js

I am recently having to deal with the following issue:

TS2339: Property 'activityTime' does not exist on type 'typeof import...'

In our project we commonly import our parameters.js as the following:

import * as params from 'parameters'

But parameters.js are kept locally and does not always contain optional configs. So the following code just gets flagged:

if (params.activityTime) {
// do something
}

We have quite a few of these throughout the project and adding @ts-ignore everywhere just gets messy.

I had thought about doing something like const p: any = params; in every place where params are imported, but that creates additional const in most of the files so I ended up discard that approach.

Without altering our parameters.js, is there a way to cast params as any?

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

0

You can declare the variable, so that TypeScript knows its type:

import * as params from './parameters';

declare const params: {
  activityTime?: number;
};
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