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?