Import in typescript
See original GitHub issueHi all,
Don’t working default import in ts, like import ky from 'ky-universal'
is undefiend
but:
const ky = require('ky-universal')
is working
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Documentation - Modules - TypeScript
Prior to TypeScript 3.8, you can import a type using import . With TypeScript 3.8, you can import a type using the import...
Read more >Import Statements in TypeScript: Which Syntax to Use
More commonly, TypeScript modules say export myFunction in which case myFunction will be one of the properties on the exported object. Use ...
Read more >How to import a module in Typescript ? - GeeksforGeeks
1. Import Default Export: In order to import the default export from a file, we can use the from location of the file...
Read more >How To Use Modules in TypeScript | DigitalOcean
To import another module available in your project, you use the relative path to the file in an import statement. In this case,...
Read more >3 Different Ways to Import Modules in TypeScript | by Wei Kang
If we were to use this method to import modules without installing the @types/node package, we will have a complaint from TypeScript as...
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 have submitted PR #17 to fix that issue @ishpartko. After it is merged and released, your workaround should no longer be necessary.
I believe this is to be expected. Unlike
ky
, which is a pure ES module,ky-universal
is a CommonJS module. I think Sindre did it this way because CommonJS is still a little easier to consume in the Node.js ecosystem.By the way, it is probably better to write:
My understanding is that
const ... require()
returns the module with typeany
, whereasimport ... require()
returns the correct type.