Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
Unable to Make Typescript Definitions Work with Javascript Class

I wrote a Node module that exports a single Javascript class. I am trying to add Typescript definitions to it for users to get good Intellisense in their IDE, but it is still causing an error I cannot solve with my limited Typescript experience.

When importing

import { AlphanumericEncoder } from 'alphanumeric-encoder';

all of the Intellisense works, but it produces this runtime error:

alphanumeric_encoder__WEBPACK_IMPORTED_MODULE_7__.AlphanumericEncoder is not a constructor

But when importing the package like this:

import AlphanumericEncoder from 'alphanumeric-encoder';

it works as expected at runtime, but the Intellisense shows an error:

This expression is not constructable.
  Type 'typeof import("/Users/z0049e1t/_GIT/Siemens/bsp1/pmd-backend/node_modules/alphanumeric-encoder/index")' has no construct signatures.ts(2351)

My index.d.ts file:

export class AlphanumericEncoder {
    constructor(configOptions?: {
        allowLowerCaseDictionary: boolean | undefined
        dictionary: string | undefined
    })
    private _defaultDictionary
    private _dictionaryInUse
    private _allowLowerCaseDictionary

    set allowLowerCaseDictionary(arg: boolean)
    get allowLowerCaseDictionary(): boolean

    set dictionary(arg: string)
    get dictionary(): string

    resetDefaultDictionary(): void

    encode(integerToEncode: number): string

    decode(stringToDecode: string): number

    deconstruct(stringToDeconstruct: string | number): number[]
}

What am I doing wrong? How do I eliminate these errors?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda