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?