Reference better-scroll in typescript

better-scroll is referenced in

typescript , the code is as follows

import * as BScroll from "better-scroll"
...
console.log(BScroll)
new BScroll(".wrapper")
...

console output

{default: , __esModule: true}
> default: BScroll(el, options)
  __esModule:true
> __proto__:Object

> Uncaught TypeError: BScroll is not a constructor
...

check the author package.json types declare no problem

...
  "types": "./types/index.d.ts",
...

check the author * .d.ts No problem

...
declare const BScroll: BScrollStatic;

declare module "better-scroll" {
  export = BScroll;
}
...

ask for help, what"s wrong with me here?

Mar.10,2022
The problem with

is that the sentence new BScroll ('.wrapper') , the
error is obvious, BScroll is not a constructor function, so you can't use the new operator.
you should be able to use this directly BScroll ('.wrapper') .


import * as BScroll from 'better-scroll'
new BScroll.BScroll();
import  BScroll from 'better-scroll'
new BScroll();

have you solved your problem? I have the same problem!


it should be the wrong way to pack. The package you may choose is cmd . Change it to iife or umd try
that's how I use it

.
 import * as BScroll from 'better-scroll'

 const styleScroll = new (<any>BScroll)(styleContainer)

@ types/better-scroll doesn't seem to be written by the author, so there seems to be a problem

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ddfb-2c3c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ddfb-2c3c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?