rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

default export? #37

Open digimbyte opened 3 years ago

digimbyte commented 3 years ago

Can you build with a Types declaration flag?

Could not find a declaration file for module 'lzwcompress'. 'c:/development/Ground Zero/functions/node_modules/lzwcompress/lzwCompress.js' implicitly has an 'any' type. Try npm i --save-dev @types/lzwcompress if it exists or add a new declaration (.d.ts) file containing declare module 'lzwcompress';

rotemdan commented 3 years ago

The library does include an lzutf8.d.ts declaration file, but it doesn't have any dependency called lzwcompress.

Maybe this message is related to another library?

digimbyte commented 3 years ago

Ah, sorry, wrong error code - that was from a library I was removing When using import lzutf8 from "lzutf8"; the following error occurs

Module '"c:/development/Ground Zero/functions/node_modules/lzutf8/build/production/lzutf8"' can only be default-imported using the 'esModuleInterop' flagts(1259) lzutf8.d.ts(9, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

rotemdan commented 3 years ago

This seems like an import error of some sort (by Angular?) Does this solution help?

Resolving Angular Default Import Errors

It recommends that instead of:

import v1 from "uuid/v1";

use:

import * as v1 from "uuid/v1";

(this example was copied and pasted from the article)

digimbyte commented 3 years ago

This is a plain Typescript project for a backend app - no framework.

rotemdan commented 3 years ago

What is the statement used to import the library?

(for example something like import * as lzutf8 from "lzutf8"..?)

digimbyte commented 3 years ago

I can wrap it as you have shown. it's not a bug, just a lack of ES default export not existing.

rotemdan commented 3 years ago

Alright, you can leave this issue open.

I'm not sure if having no default export was an intentional decision, or was chosen for some sort of compatibility reason with CommonJS (the code was written many years ago, even before ES modules were available in browsers, so having a default export didn't matter).