KnorpelSenf / typegram

TypeScript types for the entire Telegram Bot API
MIT License
122 stars 3 forks source link

Deno support #18

Closed KnorpelSenf closed 3 years ago

KnorpelSenf commented 3 years ago

Adds a quick and dirty script to derive deno-compliant TypeScript files from the current declaration files.

KnorpelSenf commented 3 years ago

@trgwii @wojpawlik please have a look at this

trgwii commented 3 years ago

This is very cool! As long as it's somewhat easy to verify that it doesn't break this should be perfect (maybe just deno run --reload deno/index.d.ts as part of some test script is enough?)

KnorpelSenf commented 3 years ago

I see that point.

We don't want to download all the types upon npm install, then everyone would get the types twice. How would we work around that?

wojpawlik commented 3 years ago

Haven't found any elegant workaround. You could publish these somewhere else (extra complexity). You could also use import specifiers with extensions, and generate *.d.ts.ts or *.d.ts.d.ts files for Node :P

I'd advise you to wait until we'll be porting Telegraf to Deno. stream is already polyfilled in Deno, but http and https aren't, so this would require moving all webhook logic to a separate file and providing a Deno reimplementaion.

wojpawlik commented 3 years ago

https://cdn.skypack.dev/typegram@3?dts sets x-typescript-types header for Deno. Trying to use it results in

error: TS2304 [ERROR]: Cannot find name 'Location'.
  location: Location;
            ~~~~~~~~
    at https://cdn.skypack.dev/-/typegram@v3.1.1-GjjXhW5hOQqkCsqEA1pP/dist=es2020,mode=types/manage.d.ts:258:13

So all you need to do is fix that (and ensure anything similar won't happen again) and explain Deno support in README.

URL imports are great!

KnorpelSenf commented 3 years ago

That sounds good.

It does not look like I will need to use Deno myself in the near future, so I'd rather avoid spending time fiddling around with deno-specific configuration.

Please open a new PR that solves this problem if it is still relevant to you.

KnorpelSenf commented 3 years ago

In case anyone finds this by now and looks for a Deno read bot framework: I used typegram as a base for building https://deno.land/x/grammy