Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!