rochars / wavefile

Create, read and write wav files according to the specs. :star: :notes: :heart:
MIT License
226 stars 48 forks source link

ES6 import syntax results in TypeError: wavefile_1.default is not a constructor #16

Closed zachschultz closed 4 years ago

zachschultz commented 4 years ago

Importing WaveFile like so: import WaveFile from "wavefile" and attempting to create an instance like: const reader = new WaveFile() results in the following error: TypeError: wavefile_1.default is not a constructor.

However, importing like: const wavefile = require("wavefile") works fine, but then TypeScript type checking stops working.

rochars commented 4 years ago

Use the --esModuleInterop flag when using ES6 imports - something like this:

$ tsc index.ts --esModuleInterop

Cheers! Rafael