-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: "not a constructor" when using TypeScript #83
Comments
Same issue here 🤷🏻♂️ I've added |
@AlberErre Above what line? I believe that TypeScript compilation is actually happening without errors, and the TypeError I'm seeing is a runtime JavaScript error. |
@danbockapps I am seeing the same thing on I was a bit confused by the suggestion from @AlberErre as well, but I realized he meant he added import Twitter from "twitter-lite"; // typings and runtime OK for this line
...
// changing your import to match above will trigger 'This expression is not constructable.'
// the @ts-ignore flag will let TS compile anyway
// @ts-ignore
const twitter = new Twitter({
consumer_key: 'XYZ',
consumer_secret: 'XYZ',
access_token_key: 'XYZ',
access_token_secret: 'XYZ'
}); |
To be clear, there are two necessary changes from the sample code in the comment at the top of index.d.ts:
In my blank project I also had to either add |
Hi all, sorry you're seeing these errors in TypeScript. We just added typings to the library, so there was bound to be some bugs 😄 That said, I'd encourage all of you to take a look to see if you can find the issue and open a PR! I'm going to cc @fdebijl since he made the PR for types originally. I'm no TS expert so hopefully we can work together to get this fixed before the next release of |
I completely overlooked Following this PR, the safe import signature (which will work without
If
Note that the |
I've had this issue with version I assume this PR would fix that: #139 |
I get this error when using the example code at the top of index.d.ts:
I reproduced this on a blank project. Just ran
npm install twitter-lite
and copied this code into a blank file and ran it using ts-node. Got the same error.The text was updated successfully, but these errors were encountered: