I have been trying to use NOTY with an Aurelia/Typescript application. Installed the package using NPM and use requireJS to pull it into the application.
No matter what I try, I have not been able to get it to work. For importing it in the file I need the reference for, I tried the following two methods
Attempt# 1
import * as Noty from 'noty';
This seems to create the right references and I can see that in code. When I try to use it, I do not get any build errors and everything seems ok.
But when I run this code, I get an error that states - "Noty is not a constructor"
Attempt 2
import Noty from 'noty'
This approach complains about no default exported members.
Another variation that I tried is import { Noty } from 'noty'; This gave me a similar response
Not sure what I am missing but any suggestions to implement this is highly appreciated. TIA
UPDATE#1
PS: Added link to NOTY if having a look at the index.d.ts file is needed.





The issue you got probably comes from the way NOTY exports their main functionality, which i guess was done in commonjs way:
To import it correctly in your code, you should use the import module syntax:
import * as NOTY from 'noty';
It's the same for many other libraries that still keep the export style of the traditional way.
Update:
Based on their type definition export: https://github.com/needim/noty/blob/master/index.d.ts#L2
This means you should always do like your attempt 1. But this is how it is actually shipped https://github.com/needim/noty/blob/master/lib/noty.js#L9-L18
Note the last part
exports["Noty"] = factory(). I suspect this is what picked up, not the first one. Which means it equals to named exportNotySo it's probably the mismatch between that export thing that caused you issue. I would suggest you do this: