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

Example causes TypeScript errors #1

Open
aslakhellesoy opened this issue May 3, 2022 · 5 comments
Open

Example causes TypeScript errors #1

aslakhellesoy opened this issue May 3, 2022 · 5 comments

Comments

@aslakhellesoy
Copy link

aslakhellesoy commented May 3, 2022

Bug report

Describe the bug

I am unable to run the checkout-integration example using various versions of Deno.

To Reproduce

For each Deno version I am running:

STRIPE_API_KEY="<YOUR API KEY HERE>" \
   deno run \
  --allow-net \
  --allow-env \
  main.js

Deno 1.16.3

error: TS1005 [ERROR]: ',' expected.
  type RequestOptions,
       ~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/node/https.ts:11:8

TS2531 [ERROR]: Object is possibly 'null'.
      actualTypeStr = actual.constructor?.name ?? "Object";
                      ~~~~~~
    at https://deno.land/[email protected]/testing/asserts.ts:375:23

TS2339 [ERROR]: Property 'ref' does not exist on type 'Listener'.
    this.#listener?.ref();
                    ~~~
    at https://deno.land/[email protected]/node/internal_binding/tcp_wrap.ts:240:21

TS2339 [ERROR]: Property 'unref' does not exist on type 'Listener'.
    this.#listener?.unref();
                    ~~~~~
    at https://deno.land/[email protected]/node/internal_binding/tcp_wrap.ts:243:21

TS2614 [ERROR]: Module '"https://deno.land/[email protected]/node/http.ts"' has no exported member 'type'. Did you mean to use 'import type from "https://deno.land/[email protected]/node/http.ts"' instead?
  type RequestOptions,
  ~~~~
    at https://deno.land/[email protected]/node/https.ts:11:3

Found 5 errors.

Deno 1.21.1

error: TS2339 [ERROR]: Property 'ref' does not exist on type 'Listener'.
    this.#listener?.ref();
                    ~~~
    at https://deno.land/[email protected]/node/internal_binding/tcp_wrap.ts:240:21

TS2339 [ERROR]: Property 'unref' does not exist on type 'Listener'.
    this.#listener?.unref();
                    ~~~~~
    at https://deno.land/[email protected]/node/internal_binding/tcp_wrap.ts:243:21

Expected behavior

No TypeScript errors

System information

  • OS: macOS
  • Server environment Deno
@riderx
Copy link

riderx commented May 12, 2022

Same on my side, many TS errors :/

error: TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
declare class URLSearchParams {
              ~~~~~~~~~~~~~~~
    at asset:///lib.deno.url.d.ts:8:15

    'URLSearchParams' was also declared here.
            interface URLSearchParams extends _URLSearchParams {}
                      ~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v78/@types/node/url.d.ts:822:19    and here.
            var URLSearchParams:
                ~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v78/@types/node/url.d.ts:843:13

TS2300 [ERROR]: Duplicate identifier 'URL'.
declare class URL {
              ~~~
    at asset:///lib.deno.url.d.ts:155:15

    'URL' was also declared here.
            interface URL extends _URL {}
                      ~~~
        at https://cdn.esm.sh/v78/@types/node/url.d.ts:823:19    and here.
            var URL:
                ~~~
        at https://cdn.esm.sh/v78/@types/node/url.d.ts:833:13

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

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

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

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

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

TS2661 [ERROR]: Cannot export 'Buffer'. Only local declarations can be exported from a module.
    export { Buffer };
             ~~~~~~
    at https://cdn.esm.sh/v78/@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/v78/@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/v78/node.ns.d.ts:7:6

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

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

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

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

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

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

TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
        interface URLSearchParams extends _URLSearchParams {}
                  ~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v78/@types/node/url.d.ts:822:19

    'URLSearchParams' was also declared here.
    declare class URLSearchParams {
                  ~~~~~~~~~~~~~~~
        at asset:///lib.deno.url.d.ts:8:15

TS2300 [ERROR]: Duplicate identifier 'URL'.
        interface URL extends _URL {}
                  ~~~
    at https://cdn.esm.sh/v78/@types/node/url.d.ts:823:19

    'URL' was also declared here.
    declare class URL {
                  ~~~
        at asset:///lib.deno.url.d.ts:155:15

TS2300 [ERROR]: Duplicate identifier 'URL'.
        var URL:
            ~~~
    at https://cdn.esm.sh/v78/@types/node/url.d.ts:833:13

    'URL' was also declared here.
    declare class URL {
                  ~~~
        at asset:///lib.deno.url.d.ts:155:15

TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
        var URLSearchParams:
            ~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v78/@types/node/url.d.ts:843:13

    'URLSearchParams' was also declared here.
    declare class URLSearchParams {
                  ~~~~~~~~~~~~~~~
        at asset:///lib.deno.url.d.ts:8:15

Found 14 errors.

@riderx
Copy link

riderx commented May 12, 2022

i found a way to get rid of the error:

import Stripe from 'https://esm.sh/[email protected]?no-check'

it stop to validate the type in stripe, it's a work around not a real fix

@aslakhellesoy
Copy link
Author

Thanks for that hack @riderx! Will try that out.

@riderx
Copy link

riderx commented Jun 27, 2022

@aslakhellesoy you can even check https://esm.sh/[email protected]?no-check&target=deno it's better

@riderx
Copy link

riderx commented Jul 8, 2022

Since we didn't get any answer for help and my production was dead because of last version of Deno who break Stripe SDK.

I did implementation of their API :
https://github.com/Cap-go/capgo/blob/5955b8dbc750ef2e9f8258cfc40a7918891b5021/supabase/functions/_utils/stripe.ts
And webhook signature check :
https://github.com/Cap-go/capgo/blob/5955b8dbc750ef2e9f8258cfc40a7918891b5021/supabase/functions/_utils/stripe_event.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants