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 is not set for type-only module #433

Closed
gr2m opened this issue Oct 10, 2022 · 12 comments
Closed

x-typescript-types header is not set for type-only module #433

gr2m opened this issue Oct 10, 2022 · 12 comments
Labels
deno Not working in Deno

Comments

@gr2m
Copy link

gr2m commented Oct 10, 2022

Failing module

import "https://esm.sh/@octokit-next/types-rest-api@2.5.0";

Error message

No error message. The x-typescript-types response header is not on esm.sh/@octokit-next/types-rest-api although they are specified, and although they exist

Additional info

  • esm.sh version: V96
  • Deno version: deno 1.26.1 (release, aarch64-apple-darwin), v8 10.7.193.3, typescript 4.8.3
@gr2m gr2m added the deno Not working in Deno label Oct 10, 2022
@gr2m
Copy link
Author

gr2m commented Oct 10, 2022

In case it's helpful, some more context. Here is an example deno script:

import { Octokit } from "https://esm.sh/@octokit-next/core";
import "https://esm.sh/@octokit-next/types-rest-api";

const octokit = new Octokit();

const { data } = await octokit.request("GET /");

// should be typed as string
data.current_user_url

When editing the above code in VS Code with the Deno extension, data is typed as unknown.

If the https://esm.sh/@octokit-next/types-rest-api import would work as expected, data.current_user_url would be typed as string. See this typescript playground for comparison

@gr2m
Copy link
Author

gr2m commented Oct 10, 2022

I was able to workaround the problem by adding a dummy export to the package:
https://esm.sh/@octokit-next/types-rest-api@2.5.1

@ije
Copy link
Member

ije commented Oct 11, 2022

thanks for the details, I will add support for type only package!

@gr2m
Copy link
Author

gr2m commented Jan 23, 2023

@ije did you have a chance to look into it? No worries if not, just checking in

@ije
Copy link
Member

ije commented Jan 23, 2023

currently if you import module from https://github.com/@types/react, it will redirect to https://esm.sh/v104/@types/react@18.0.27/index.d.ts, i don't know if it works for types-rest-api? i saw you added a workaround to exports, maybe just remove it?

@gr2m
Copy link
Author

gr2m commented Jan 25, 2023

the problem persists.

# no "x-typescript-types" header in v2.5.0
curl https://esm.sh/@octokit-next/types-rest-api@2.5.0\?dev -I | grep x-typescript-types:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    21    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0

# header is present after adding a dummy code export
curl https://esm.sh/@octokit-next/types-rest-api@2.5.1\?dev -I | grep x-typescript-types:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   278    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
x-typescript-types: https://esm.sh/v104/@octokit-next/types-rest-api@2.5.1/index.d.ts

@ije
Copy link
Member

ije commented Jan 25, 2023

ok, i will fix this asap, thanks

@zeke
Copy link

zeke commented May 3, 2023

Hi @ije. My team is blocked by this in https://github.com/replicate/openapi

Anything needed to help unblock a fix for it?

@ije
Copy link
Member

ije commented May 3, 2023

Hi @ije. My team is blocked by this in https://github.com/replicate/openapi

@zeke I'm trying to fix this, but i can't access the repository, can you please provide a npm name instead? thanks!

@ije
Copy link
Member

ije commented May 3, 2023

In case it's helpful, some more context. Here is an example deno script:

import { Octokit } from "https://esm.sh/@octokit-next/core";
import "https://esm.sh/@octokit-next/types-rest-api";

const octokit = new Octokit();

const { data } = await octokit.request("GET /");

// should be typed as string
data.current_user_url

When editing the above code in VS Code with the Deno extension, data is typed as unknown.

If the https://esm.sh/@octokit-next/types-rest-api import would work as expected, data.current_user_url would be typed as string. See this typescript playground for comparison

i fixed the x-typescript-types header in v119, but can not get the demo to work

@gr2m
Copy link
Author

gr2m commented May 16, 2023

i fixed the x-typescript-types header in v119, but can not get the demo to work

Might be something else.

I can confirm that the access-control-expose-headers header is now set

curl https://esm.sh/@octokit-next/types-rest-api@2.5.0\?dev -I                           
HTTP/2 200 
date: Tue, 16 May 2023 16:58:34 GMT
content-type: application/javascript; charset=utf-8
access-control-allow-origin: *
cache-control: public, max-age=86400
vary: Origin,User-Agent
access-control-allow-methods: *
access-control-expose-headers: X-TypeScript-Types
x-typescript-types: https://esm.sh/v121/@octokit-next/types-rest-api@2.5.0/index.d.ts
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=qbLGsa2Dg%2BgvjV3aVJHoHl5vo3YusUEP4J6%2FljsZNQK5PtZcK19h36Kfke9jwbizWPziBtd7I%2BCainXfgbG%2FXiaBvOoct18d%2BLWRThjsClxrCJ5LQxc65fQ%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 7c852a8d6aa67c67-LAX
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

I think it's safe to close this issue. I'll open a new one once I find out what causes the problem with the Deno Script.

@gr2m gr2m closed this as completed May 16, 2023
@ije
Copy link
Member

ije commented May 17, 2023

@gr2m thanks 🙏

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