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

x-typescript-types header ignores module version and deps version #234

Open
KyleJune opened this issue Dec 19, 2021 · 1 comment
Open

x-typescript-types header ignores module version and deps version #234

KyleJune opened this issue Dec 19, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@KyleJune
Copy link

Issue

If you try to use the react module pinned to 17.0.2, it ignores the version when choosing the x-typescript-types header. Below is the url I used and the types header I got for it. The types header should be 17.0.2 like the module I'm importing.

https://esm.sh/react@17.0.2

x-typescript-types
https://cdn.esm.sh/v58/@types/react@17.0.35/index.d.ts

This also applies to deps. If I make a request to the following, the types has no information about the dependency versions. In this example, the types ends up importing "https://cdn.esm.sh/v58/@types/react@17.0.37/index.d.ts" which is the wrong version of react. Having 2 different types files for react causes typescript errors due to duplicate identifiers.

https://esm.sh/react-router-dom@6.2.1?deps=react@17.0.2,history@5.1.0

x-typescript-types
https://cdn.esm.sh/v58/react-router-dom@6.2.1/index.d.ts

error: TS2300 [ERROR]: Duplicate identifier 'LibraryManagedAttributes'.
        type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
             ~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v58/@types/react@17.0.35/index.d.ts:3100:14

    'LibraryManagedAttributes' was also declared here.
            type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
                 ~~~~~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v58/@types/react@17.0.37/index.d.ts:3100:14

Additional info

  • esm.sh version: v58
@KyleJune KyleJune added the bug Something isn't working label Dec 19, 2021
@KyleJune
Copy link
Author

It appears most other react based modules are using 17.0.37. to resolve this error I import 17.0.2 but use a deno types comment to have it use the 17.0.37 types instead of the 17.0.35 types from the x-typesceipt-types header.

Ideally the types would always match the version specified. I think I might have tried 17.0.2 types but they were not working. I don't recall.

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

1 participant