Escribí un módulo Node que exporta una sola clase de Javascript. Estoy tratando de agregarle definiciones de Typescript para que los usuarios obtengan un buen Intellisense en su IDE, pero todavía está causando un error que no puedo resolver con mi experiencia limitada de Typescript.
Al importar
import { AlphanumericEncoder } from 'alphanumeric-encoder';todo el Intellisense funciona, pero produce este error de tiempo de ejecución:
alphanumeric_encoder__WEBPACK_IMPORTED_MODULE_7__.AlphanumericEncoder is not a constructorPero al importar el paquete así:
import AlphanumericEncoder from 'alphanumeric-encoder';funciona como se esperaba en tiempo de ejecución, pero Intellisense muestra un 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)Mi archivo index.d.ts :
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[] }¿Qué estoy haciendo mal? ¿Cómo elimino estos errores?