question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import in typescript

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sholladaycommented, Apr 20, 2020

I have submitted PR #17 to fix that issue @ishpartko. After it is merged and released, your workaround should no longer be necessary.

1reaction
sholladaycommented, Apr 20, 2020

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:

import ky = require('ky-universal');

My understanding is that const ... require() returns the module with type any, whereas import ... require() returns the correct type.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found