Typescript import doesn't work.
See original GitHub issueWhen 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Import statement does not work in typescript - Stack Overflow
Then I'm trying to import a class in a file using 'import' keyword. But despite having read about the declaration of modules in...
Read more >Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports ; 'view/file2' with the first location in the array ( ; "*" ), and combine...
Read more >Imports not working in TypeScript project. · Issue #199 - GitHub
When I am trying to import any of the Props into a TypeScript project, import sizes from "open-props/src/sizes" I get a ts(2307) Error:...
Read more >Documentation - Module Resolution - TypeScript
If you are having resolution problems with import s and export s in TypeScript, try setting moduleResolution: "node" to see if it fixes...
Read more >Import Statements in TypeScript: Which Syntax to Use
This doesn't work when the module doesn't export an object with properties. Some modules export a function or a class instead.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not that familiar with typescript, but looking at https://github.com/Microsoft/TypeScript/issues/3337#issuecomment-107971371; did you try this?
Looking at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/analytics-node/index.d.ts I think you’re supposed to import like this: