Hola a todos, acabo de implementar bn.js en el validador de clase DTO. Y obtuve un error como este:
TypeError: bn_js_1.default no es un constructor en Object.transformFn
¿alguien puede ayudarme? aquí está el DTO:
import BN from 'bn.js'; import { Transform } from 'class-transformer'; export class IWCreateNftCollectionV1ReqDTO { @Transform(({ value }) => new BN(value.toString())) royalties:BN; }Y el paquete.json
"dependencies": { "@types/bn.js": "^5.1.0", "bn.js": "^5.2.0" }Gracias
ACTUALIZAR Resuelto agregando abajo en tsconfig.json
{ "compilerOptions": { ... "esModuleInterop": true, }, }Parece que bn.js no usa exportaciones predeterminadas. Puede configurar esModuleInterop: true en su tsconfig , o debería poder import * as BN from 'bn.js'; si no quieres modificar esa configuración