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

Typings not being loaded for "dedent" NPM package #576

Closed
heyajulia opened this issue Mar 31, 2023 · 8 comments
Closed

Typings not being loaded for "dedent" NPM package #576

heyajulia opened this issue Mar 31, 2023 · 8 comments
Labels
deno Not working in Deno

Comments

@heyajulia
Copy link

Failing module

import dedent from "https://esm.sh/v113/[email protected]";

Error message

There's no error message per se, but typings are not loaded, so the function typed as any when I mouse over it in Visual Studio Code (even though typings are available). As a workaround, I'm using https://cdn.skypack.dev/[email protected]?dts, which does work as expected.

Additional info

  • esm.sh version: 113 (I think)
  • Deno version:
deno 1.32.0 (release, x86_64-unknown-linux-gnu)
v8 11.2.214.9
typescript 5.0.2
@heyajulia heyajulia added the deno Not working in Deno label Mar 31, 2023
@echoptic
Copy link

echoptic commented Apr 5, 2023

having the same issue with dayjs. when importing from 'npm:' the types work.

import dayjs from "https://esm.sh/v113/[email protected]";
import relativeTime from "https://esm.sh/v113/[email protected]/plugin/relativeTime.js";

dayjs.extend(relativeTime);

  // @ts-ignore Deno doesn't recognize the function fromNow
  const ago = dayjs(props.time * 1000).fromNow();

@ije
Copy link
Member

ije commented Apr 5, 2023

@heyajulia but seems there is no types defined in the package.json

@ije
Copy link
Member

ije commented Apr 5, 2023

@echoptic this is known issue, because currently the dts transformer can handle module extend well

// esm.sh ignores below types
declare module 'dayjs' {
  interface Dayjs {
    fromNow(withoutSuffix?: boolean): string
    from(compared: ConfigType, withoutSuffix?: boolean): string
    toNow(withoutSuffix?: boolean): string
    to(compared: ConfigType, withoutSuffix?: boolean): string
  }
}

i will fix it later

@echoptic
Copy link

echoptic commented Apr 5, 2023

@ije I'm interested in helping somehow if possible. Is there a related issue open for this?

@heyajulia
Copy link
Author

@heyajulia but seems there is no types defined in the package.json

I see that's true; I did not know that was a requirement. I'm guessing Skypack tries to look for (and finds) @types/dedent in that case, and esm.sh doesn't.

@ije
Copy link
Member

ije commented Apr 5, 2023

I'm guessing Skypack tries to look for (and finds) @types/dedent in that case, and esm.sh doesn't.

@types/dedent doesn't define the types field neither, but should use index.d.ts instead. i will fix!

@ije ije closed this as completed in e387248 Apr 5, 2023
@ije
Copy link
Member

ije commented Apr 5, 2023

@ije I'm interested in helping somehow if possible. Is there a related issue open for this?

@echoptic can you please open another issue we can discuss? thanks

@echoptic
Copy link

echoptic commented Apr 5, 2023

@ije oppened #581

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

No branches or pull requests

3 participants