Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting types in @types/node and node.ns.d.ts #143

Closed
talentlessguy opened this issue Sep 14, 2021 · 7 comments
Closed

Conflicting types in @types/node and node.ns.d.ts #143

talentlessguy opened this issue Sep 14, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@talentlessguy
Copy link
Contributor

talentlessguy commented Sep 14, 2021

Some of the Node.js-targeted modules have type conflicts because esm.sh uses both the @types/node and node.ns.d.ts types, resulting in Duplicate identifier.

For example, [email protected]:

➜ deno run /tmp/deno.ts
Download http://localhost:3333/ipfs-http-client
Download http://localhost:3333/v50/[email protected]/hashes/interface...d.ts
Download http://localhost:3333/v50/[email protected]/cid...d.ts
Download http://localhost:3333/v50/[email protected]/bases/interface...d.ts
Download http://localhost:3333/v50/[email protected]/codecs/interface...d.ts
Check file:///tmp/deno.ts
error: TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
     ~~~~~~~~~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:7:6

    'BufferEncoding' was also declared here.
            type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
                 ~~~~~~~~~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:171:14

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
type WithImplicitCoercion<T> = T | { valueOf(): T };
     ~~~~~~~~~~~~~~~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:9:6

    'WithImplicitCoercion' was also declared here.
            type WithImplicitCoercion<T> =
                 ~~~~~~~~~~~~~~~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:172:14

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
declare class Buffer extends Uint8Array {
              ~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:16:15

    'Buffer' was also declared here.
            interface Buffer extends Uint8Array {
                      ~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:532:19    and here.
            var Buffer: BufferConstructor;
                ~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:2106:13

or stripe:

➜ deno run /tmp/deno.ts
Check file:///tmp/deno.ts
error: TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
     ~~~~~~~~~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:7:6

    'BufferEncoding' was also declared here.
            type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
                 ~~~~~~~~~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:171:14

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
type WithImplicitCoercion<T> = T | { valueOf(): T };
     ~~~~~~~~~~~~~~~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:9:6

    'WithImplicitCoercion' was also declared here.
            type WithImplicitCoercion<T> =
                 ~~~~~~~~~~~~~~~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:172:14

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
declare class Buffer extends Uint8Array {
              ~~~~~~
    at http://localhost:3333/v50/node.ns.d.ts:16:15

    'Buffer' was also declared here.
            interface Buffer extends Uint8Array {
                      ~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:532:19    and here.
            var Buffer: BufferConstructor;
                ~~~~~~
        at http://localhost:3333/v50/@types/node/buffer.d.ts:2106:13

TS2661 [ERROR]: Cannot export 'Buffer'. Only local declarations can be exported from a module.
    export { Buffer };
             ~~~~~~
    at http://localhost:3333/v50/@types/node/buffer.d.ts:98:14

TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
        type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
             ~~~~~~~~~~~~~~
    at http://localhost:3333/v50/@types/node/buffer.d.ts:171:14

    'BufferEncoding' was also declared here.
    type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
         ~~~~~~~~~~~~~~
        at http://localhost:3333/v50/node.ns.d.ts:7:6

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
        type WithImplicitCoercion<T> =
             ~~~~~~~~~~~~~~~~~~~~
    at http://localhost:3333/v50/@types/node/buffer.d.ts:172:14

    'WithImplicitCoercion' was also declared here.
    type WithImplicitCoercion<T> = T | { valueOf(): T };
         ~~~~~~~~~~~~~~~~~~~~
        at http://localhost:3333/v50/node.ns.d.ts:9:6

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        interface Buffer extends Uint8Array {
                  ~~~~~~
    at http://localhost:3333/v50/@types/node/buffer.d.ts:532:19

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at http://localhost:3333/v50/node.ns.d.ts:16:15

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        var Buffer: BufferConstructor;
            ~~~~~~
    at http://localhost:3333/v50/@types/node/buffer.d.ts:2106:13

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at http://localhost:3333/v50/node.ns.d.ts:16:15

Found 8 errors.
@talentlessguy talentlessguy added the bug Something isn't working label Sep 14, 2021
@ije
Copy link
Member

ije commented Sep 14, 2021

hmmm, hard to make every types of nodejs work, but i will look into it, good news is at least the @tyeps/node/query is working~

@talentlessguy
Copy link
Contributor Author

Same happens with typechain

Check file:///tmp/deno.ts
error: TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
     ~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v53/node.ns.d.ts:7:6

    'BufferEncoding' was also declared here.
            type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
                 ~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:171:14

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
type WithImplicitCoercion<T> = T | { valueOf(): T };
     ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v53/node.ns.d.ts:9:6

    'WithImplicitCoercion' was also declared here.
            type WithImplicitCoercion<T> =
                 ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:172:14

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
declare class Buffer extends Uint8Array {
              ~~~~~~
    at https://cdn.esm.sh/v53/node.ns.d.ts:16:15

    'Buffer' was also declared here.
            interface Buffer extends Uint8Array {
                      ~~~~~~
        at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:532:19    and here.
            var Buffer: BufferConstructor;
                ~~~~~~
        at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:2106:13

TS2661 [ERROR]: Cannot export 'Buffer'. Only local declarations can be exported from a module.
    export { Buffer };
             ~~~~~~
    at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:98:14

TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
        type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
             ~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:171:14

    'BufferEncoding' was also declared here.
    type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
         ~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v53/node.ns.d.ts:7:6

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
        type WithImplicitCoercion<T> =
             ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:172:14

    'WithImplicitCoercion' was also declared here.
    type WithImplicitCoercion<T> = T | { valueOf(): T };
         ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v53/node.ns.d.ts:9:6

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        interface Buffer extends Uint8Array {
                  ~~~~~~
    at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:532:19

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at https://cdn.esm.sh/v53/node.ns.d.ts:16:15

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        var Buffer: BufferConstructor;
            ~~~~~~
    at https://cdn.esm.sh/v53/@types/node/buffer.d.ts:2106:13

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at https://cdn.esm.sh/v53/node.ns.d.ts:16:15

Found 8 errors.

@ebramanti
Copy link

Seeing the same with @solana/web3.js on v1.29.2.

@ebramanti
Copy link

Bumping this, still seeing this issue on the latest version of @solana/web3.js (v1.31.0).

@zicklag
Copy link

zicklag commented Nov 28, 2021

I'm running into an issue with Solana, too. I'm not sure I can help, but are there any pointers for how to go about fixing this?

My error is different, though:

error: Uncaught SyntaxError: The requested module '/v57/[email protected]/deno/js-sha3.js' does not provide an export named 'keccak_256'
    at <anonymous> (https://cdn.esm.sh/v57/@solana/[email protected]/deno/web3.js:2:1538)

@ebramanti
Copy link

I'm running into an issue with Solana, too. I'm not sure I can help, but are there any pointers for how to go about fixing this?

My error is different, though:


error: Uncaught SyntaxError: The requested module '/v57/[email protected]/deno/js-sha3.js' does not provide an export named 'keccak_256'

    at <anonymous> (https://cdn.esm.sh/v57/@solana/[email protected]/deno/web3.js:2:1538)

Open issue for this, #221

@ije
Copy link
Member

ije commented Jul 28, 2022

fix deno/buffer types in v88

@ije ije closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants