tobilg / aws-edge-locations

List of AWS edge location code prefixes
MIT License
57 stars 9 forks source link

bug: TypeScript default import #14

Open jlarmstrongiv opened 10 months ago

jlarmstrongiv commented 10 months ago

The default package import is broken for me. My workaround is

import AWSEdgeLocations from "aws-edge-locations";

const awsEdgeLocations =
  // @ts-expect-error Property 'default' does not exist on type 'typeof AWSEdgeLocations'
  new AWSEdgeLocations.default() as InstanceType<typeof AWSEdgeLocations>;

Using named exports usually avoids many of the default or module.exports = issues

tobilg commented 9 months ago

Hm, I can use it with

import AWSEdgeLocations  from "aws-edge-locations";
// Get AWS Edge Locations
const awsEdgeLocations = new AWSEdgeLocations();

I have released a new version today, can you check if this problem persists on your end?

jlarmstrongiv commented 9 months ago

Unfortunately, the import is still broken in the latest aws-edge-locations@0.5.3

npx esno packages/core/src/logs/jsonHandlerDemo.ts
/Users/user/Desktop/projects/project/packages/core/src/logs/jsonHandler.ts:12
const awsEdgeLocations = new AWSEdgeLocations();
                         ^

TypeError: AWSEdgeLocations is not a constructor
    at <anonymous> (/Users/user/Desktop/projects/project/packages/core/src/logs/jsonHandler.ts:12:26)

Node.js v20.11.1

I don’t know if the tsconfig settings are relevant, but I’m using these tsconfigs, which use settings like:

// Properly support importing CJS modules in ESM
"esModuleInterop": true,

Also, just wanted to say a big thank you @tobilg for writing your blog. I was trying to do something similar to your Casual data engineering, or: A poor man's Data Lake in the cloud article for my website, and your idea of using duckdb is brilliant. I would love to learn more about it.

tobilg commented 3 weeks ago

Can you please try again with 0.6.1?

jlarmstrongiv commented 2 weeks ago

@tobilg Unfortunately, I tried with the latest version, but still have the same error