Giter Site home page Giter Site logo

RFC: Exportable types about workers-types HOT 7 CLOSED

penalosa avatar penalosa commented on July 18, 2024 2
RFC: Exportable types

from workers-types.

Comments (7)

penalosa avatar penalosa commented on July 18, 2024 1

@GregBrimble

  1. No, because a class is both a type and a value, whereas const Response = globalThis.Response is just a value. To get the type of Response, you'd need to use typeof Response, which breaks the usual expectation for classes. That's an okay tradeoff for functions, because you need typeof for functions anyway (I'm pretty sure, at least).
  2. Yes, this would be just another option

from workers-types.

GregBrimble avatar GregBrimble commented on July 18, 2024

Does Frankenstein's approach work for the other types as well? Any reason not to do that and be consistent on everything?

from workers-types.

GregBrimble avatar GregBrimble commented on July 18, 2024

Additionally, can we keep the global types for those that want to continue using workers-types in the v2 way?

from workers-types.

penalosa avatar penalosa commented on July 18, 2024

If we publish an ambient index.d.ts and an importable index.ts, existing code should keep working, and you'll also be able to import. Something to consider (cc @mrbbot), do we also want to try and publish to a @types/cloudflare-workers or something like that?

from workers-types.

GregBrimble avatar GregBrimble commented on July 18, 2024

Hey @jacob-ebey, we're thinking about publishing importable Workers runtime types, as well as continuing to offer the global types. Do you have any thoughts on this? Would there be interest in using the importable types in the Remix packages/templates? Or does it make sense only for users to use directly themselves?

from workers-types.

mrbbot avatar mrbbot commented on July 18, 2024

We should be able to close all these issues if we do this:

from workers-types.

mrbbot avatar mrbbot commented on July 18, 2024

I'm going to close this, as you can now import type { ... } from "@cloudflare/workers-types" as of @cloudflare/workers-types version 4.

from workers-types.

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.