GithubHelp home page GithubHelp logo

Worker type definitions? about denoflare HOT 6 CLOSED

skymethod avatar skymethod commented on August 20, 2024 1
Worker type definitions?

from denoflare.

Comments (6)

JustinGrote avatar JustinGrote commented on August 20, 2024

So using the "official" Cloudflare types is blocked on cloudflare/workers-types#199

until they fix how they present things, we're stuck with our own bespoke types. I've been working on some new well-documented types for the module worker syntax for my own use, which is a lot easier to encapsulate things than with the "globals" syntax, but yeah right now it's a bit painful.

from denoflare.

johnspurlock-skymethod avatar johnspurlock-skymethod commented on August 20, 2024

Yea I've been maintaining my own types (in that cloudflare_workers_types.d.ts) from back before the official types file even existed.

Still find it useful as the the official one lags behind (esp for new cf alpha/beta services) and doesn't play nice with Deno.

I would like to have cloudflare_workers_types.d.ts reflect the current cloudflare production runtime as much as possible, so if you know of any specific differences that you are relying on in production, please raise them as issues/PRs on that file. Only thing to keep in mind is that denoflare's fakes/stubs/proxies may need to change along with any core type changes.

from denoflare.

johnspurlock-skymethod avatar johnspurlock-skymethod commented on August 20, 2024

@ylxdzsw The latest release v0.5.10 allows the no-options version of KVNamespace.get. There are still advantages to maintaining a Deno-friendly and forward-looking version of these types, so our cloudflare_workers_types.d.ts isn't going anywhere any time soon.

from denoflare.

JustinGrote avatar JustinGrote commented on August 20, 2024

For anyone following, the @cloudflare/workers-types was updated so that it is now partially importable to avoid the conflicts that used to occur. I haven't tested it with denoflare but it may be easier to use at least a subset of the types now since they dont have to be global and things like "blob" should no longer conflict.

from denoflare.

JustinGrote avatar JustinGrote commented on August 20, 2024

To follow up, I tested and this works great using unpkg:

import { Request, ExecutionContext } from "https://unpkg.com/@cloudflare/[email protected]/experimental/index.ts"
import * as semVer from "https://deno.land/[email protected]/semver/mod.ts"

export default {
	async fetch() {
		const res = `Hello World! ${semVer.increment("1.2.3", "patch")}`
		console.log(res)
		return new Response(res);
	},
};

{E445681E-DE3C-4446-9C26-589DD43D808F}

from denoflare.

johnspurlock-skymethod avatar johnspurlock-skymethod commented on August 20, 2024

Nice, I could see migrating over to these piecemeal (re-exporting) in our types file where duplicative, and just keeping our file for the bleeding edge services that are not in workers-types yet.

I gave them some feedback about better jsdocs, and they are working on it. That's another advantage our types still have in some cases.

from denoflare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.