octokit.js: [BUG]: types don't resolve for `@octokit/core` on esm.sh

What happened?

deno check ... consistently errors when using octokit via esm.sh

Versions

Octokit.js v4.0.2 Deno v2.0.6

Relevant log output

$ deno check *.ts **/*.ts --allow-import
error: Failed resolving types. Relative import path "@octokit/core/types" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/octokit@4.0.2/X-ZS8q/dist-types/octokit.d.ts"
    at https://esm.sh/v135/octokit@4.0.2/X-ZS8q/dist-types/octokit.d.ts:4:59
$

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

We still have this issue to contend with, https://github.com/esm-dev/esm.sh/issues/995.

I got rid of all @types/node on the Octokit side of things

I got deno check to work:

{
  "imports": {
    "octokit": "https://esm.sh/v135/*octokit@4.1.0?target=deno",
    "_http_agent": "node:_http_agent",
    "_http_client": "node:_http_client",
    "_http_common": "node:_http_common",
    "_http_incoming": "node:_http_incoming",
    "_http_outgoing": "node:_http_outgoing",
    "_http_server": "node:_http_server",
    "_stream_duplex": "node:_stream_duplex",
    "_stream_passthrough": "node:_stream_passthrough",
    "_stream_readable": "node:_stream_readable",
    "_stream_transform": "node:_stream_transform",
    "_stream_wrap": "node:_stream_wrap",
    "_stream_writable": "node:_stream_writable",
    "_tls_common": "node:_tls_common",
    "_tls_wrap": "node:_tls_wrap",
    "assert": "node:assert",
    "assert/strict": "node:assert/strict",
    "async_hooks": "node:async_hooks",
    "buffer": "node:buffer",
    "child_process": "node:child_process",
    "cluster": "node:cluster",
    "console": "node:console",
    "constants": "node:constants",
    "crypto": "node:crypto",
    "dgram": "node:dgram",
    "diagnostics_channel": "node:diagnostics_channel",
    "dns": "node:dns",
    "dns/promises": "node:dns/promises",
    "domain": "node:domain",
    "events": "node:events",
    "fs": "node:fs",
    "fs/promises": "node:fs/promises",
    "http": "node:http",
    "http2": "node:http2",
    "https": "node:https",
    "inspector": "node:inspector",
    "inspector/promises": "node:inspector/promises",
    "module": "node:module",
    "net": "node:net",
    "os": "node:os",
    "path": "node:path",
    "path/posix": "node:path/posix",
    "path/win32": "node:path/win32",
    "perf_hooks": "node:perf_hooks",
    "process": "node:process",
    "punycode": "node:punycode",
    "querystring": "node:querystring",
    "readline": "node:readline",
    "readline/promises": "node:readline/promises",
    "repl": "node:repl",
    "stream": "node:stream",
    "stream/consumers": "node:stream/consumers",
    "stream/promises": "node:stream/promises",
    "stream/web": "node:stream/web",
    "string_decoder": "node:string_decoder",
    "sys": "node:sys",
    "timers": "node:timers",
    "timers/promises": "node:timers/promises",
    "tls": "node:tls",
    "trace_events": "node:trace_events",
    "tty": "node:tty",
    "url": "node:url",
    "util": "node:util",
    "util/types": "node:util/types",
    "v8": "node:v8",
    "vm": "node:vm",
    "wasi": "node:wasi",
    "worker_threads": "node:worker_threads",
    "zlib": "node:zlib"
  },
  "scopes": {
    "https://esm.sh/v135/": {
      "@octokit/app": "https://esm.sh/v135/@octokit/app@15.1.2?target=deno",
      "@octokit/auth-app": "https://esm.sh/v135/@octokit/auth-app@7.1.4?target=deno",
      "@octokit/auth-unauthenticated": "https://esm.sh/v135/@octokit/auth-unauthenticated@6.1.1?target=deno",
      "@octokit/core": "https://esm.sh/v135/@octokit/core@6.1.3?target=deno",
      "@octokit/core/types": "https://esm.sh/v135/@octokit/core@6.1.3/dist-types/types.d.ts?target=deno",
      "@octokit/oauth-app": "https://esm.sh/v135/@octokit/oauth-app@7.1.5?target=deno",
      "@octokit/plugin-paginate-graphql": "https://esm.sh/v135/@octokit/plugin-paginate-graphql@5.2.4?deps=@octokit/core@6.1.3",
      "@octokit/plugin-paginate-rest": "https://esm.sh/v135/@octokit/plugin-paginate-rest@11.4.0?target=deno",
      "@octokit/plugin-rest-endpoint-methods": "https://esm.sh/v135/@octokit/plugin-rest-endpoint-methods@13.3.0?target=deno",
      "@octokit/plugin-retry": "https://esm.sh/v135/@octokit/plugin-retry@7.1.3?target=deno",
      "@octokit/plugin-throttling": "https://esm.sh/v135/@octokit/plugin-throttling@9.4.0?target=deno",
      "@octokit/request-error": "https://esm.sh/v135/@octokit/request-error@6.1.6?target=deno",
      "@octokit/types": "https://esm.sh/v135/@octokit/types@13.7.0?target=deno",
      "@octokit/webhooks": "https://esm.sh/v135/@octokit/webhooks@13.4.2?target=deno"
    }
  }
}

The octokit module is built on multiple other Octokit libraries packaged together, like @octokit/core, @octokit/app, @octokit/webhooks.

Sorry, I meant export map https://nodejs.org/api/packages.html#exports

It defines the exports of that package, in that case, there’s 2 exports. ./ is the main entrypoint ./types is a special entrypoint to access some types not exported in the main entrypoint but needed elsewhere.

The problem lies with esm.sh not using the export map in order to map the import to the correct file.

In the mean time, try adding the following to your scopes

"@octokit/core/types": "https://esm.sh/v135/@octokit/core@6.1.2/dist-types/types.d.ts",

Also, to prevent any type errors ditch the @octokit/webhooks-types package in favour of the @octokit/openapi-webhooks-types package. The former are not compatible with v4 of Octokit