esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Failed to import - octokit (types)

Open thisguycodes opened this issue 2 years ago • 11 comments

Failing module

  • GitHub: https://github.com/octokit/octokit.js
  • npm: https://www.npmjs.com/package/octokit
import { App } from "https://esm.sh/octokit"

Error message

from a blank directory:

$ deno run -A -r https://esm.sh init
$ deno task esm:add octokit

make test.ts with the following contents:

import { App } from "https://esm.sh/octokit"

After running deno check test.ts I got this:

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/[email protected]/X-ZS8q/dist-types/octokit.d.ts"
    at https://esm.sh/v135/[email protected]/X-ZS8q/dist-types/octokit.d.ts:4:59

Additional info

  • esm.sh version: v135
  • Deno version: v2.0.6

thisguycodes avatar Nov 19 '24 22:11 thisguycodes

at first I thought this might be an octokit issue (I had found something else already). I opened an issue there first and they showed the mapping exists.

thisguycodes avatar Nov 19 '24 22:11 thisguycodes

This issue was already fixed in @octokit/app https://github.com/octokit/app.js/pull/583

wolfy1339 avatar Nov 19 '24 22:11 wolfy1339

I'm thinking you meant the other issue, where it can't resolve @octokit/core/types

$ 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/[email protected]/X-ZS8q/dist-types/octokit.d.ts"
    at https://esm.sh/v135/[email protected]/X-ZS8q/dist-types/octokit.d.ts:4:59

Which has to do with exports map, and a type only import

wolfy1339 avatar Nov 19 '24 22:11 wolfy1339

@wolfy1339 yes. I linked to both issues. I pasted the wrong logs here.

thisguycodes avatar Nov 19 '24 22:11 thisguycodes

@wolfy1339 although idk why but https://esm.sh/octokit still seems to be resolving to the older version of @octokit/app

thisguycodes avatar Nov 19 '24 22:11 thisguycodes

i will look into it

ije avatar Nov 20 '24 08:11 ije

seems it's the type checking changed in deno 2, deno 1.x works fine Screenshot 2024-11-20 at 16 34 15 Screenshot 2024-11-20 at 16 34 49

ije avatar Nov 20 '24 08:11 ije

related to https://github.com/denoland/deno/issues/25762

ije avatar Nov 20 '24 08:11 ije

That particular issue was resolved, it was a bug in the package. Can you please update @octokit/app on esm.sh

You need to force it to use @octokit/[email protected] in order to actually experience the issue described here

wolfy1339 avatar Nov 20 '24 20:11 wolfy1339

@wolfy1339 thanks

ije avatar Jan 06 '25 04:01 ije

I'm not sure we understood each other. The previous comment I made was about the file web.d.ts not existing and not about the issue as a whole.

The issue is still going on, and it isn't about module augmentation in types but package.json exports.

ESM.sh isn't resolving the import of @octokit/core/types to @octokit/core/dist-types/types.d.ts as defined in the exports map in the package.json

https://unpkg.com/browse/@octokit/[email protected]/package.json#L64

wolfy1339 avatar Jan 06 '25 14:01 wolfy1339