-
Notifications
You must be signed in to change notification settings - Fork 151
Typescript import doesn't work. #132
Comments
I'm not that familiar with typescript, but looking at microsoft/TypeScript#3337 (comment); did you try this?
|
When I use that type of import I get the following error: Removing the type definitions completely fixes this problem. This is unfortunate :(. |
I'm not too sure how TypeScript works, but how is it expecting us to export the Analytics class? I think this may be an issue with |
Looking at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/analytics-node/index.d.ts I think you're supposed to import like this:
|
hey @ashok-sc , could you try @lev-kuznetsov 's suggestion? Closing this issue for now, but please re-open if it's still an issue. |
@f2prateek it's definitely not working and issue need to be reopened |
This should be reopened. This is still an issue. |
I don't think this is the right place for the issue- the issue is from wherever your analytics-node types are being defined, which is outside of this repostiroty, e.g. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/analytics-node/index.d.ts. You should open this issue for whichever library is the one you're using to package the TypeScript information. |
@f2prateek Some packages declare their own types inside the home repo. +1 for doing that here |
@ajsharp seems reasonable - I closed the issue because the original post was reporting a bug in a different package. Feel free to open a new issue if you'd like to request TypeScript support natively in this package. I'm not sure if we'll add it soon, but it would serve as a good forum for people to track the issue and show their interest. |
IMO, since Segment doesn't use TypeScript here, the definitions don't really belong here either. Putting them in this repository is just putting additional maintenance on the Segment team that isn't completely necessary, since the @DefinitelyTyped org exists. |
I'm sorry @stephenmathieson that is such a bad argument. It's like saying that the Docs should live in a different repo because you only ever look at the code internally anyways. Any other language then Javascript you would have had to type your classes, only in JS world does it suddenly become a "strain on the team to maintain". That's what open source is for, I would be more then happy to have made a PR here to fix the issue but adding the Type definitions to this repo at least shows that you care about the developers that use this library. Now I wouldn't have even commented if this was a community driven project, (although I would have proposed including the TS anyways) but you are a developer-focussed for profit business, so I feel a response like, "we're not going to help because the typings aren't part of this repo" is a bit rude. |
BTW, this is the solution DefinitelyTyped/DefinitelyTyped#23760 |
It's nothing like that. TypeScript is not JavaScript, so the JavaScript developers that maintain this project are going to do a bad job at maintaining the TS definitions. Just because you decided to learn TypeScript does not mean Segment's JS devs have. When I was still there, there were literally no TypeScript projects in the entire |
@RXminuS so, does it mean that solution is to use |
When importing Analytics using Typescript:
import Analytics from 'analytics-node';
I get the following error:
node_modules/@types/analytics-node/index"' has no default export.
I can revert to this
const Analytics = require('analytics-node');
, but I should be able to do this with Typescript imports right?As you can see above, I do have the type definitions installed as well.
The text was updated successfully, but these errors were encountered: