Giter Site home page Giter Site logo

Comments (10)

jdanyow avatar jdanyow commented on June 30, 2024 1

Any chance these name changes could be reverted? They make it difficult for packages targeting both cloudflare workers and service workers.

from workers-types.

lookfirst avatar lookfirst commented on June 30, 2024 1

I'd say focus 100% on making standards work so that there is a clean API that end-users of this library can most easily port over other existing standard code. This open issue is a substantial regression.

from workers-types.

lookfirst avatar lookfirst commented on June 30, 2024

RequestInit -> RequestInitializerDict

from workers-types.

lookfirst avatar lookfirst commented on June 30, 2024

BodyInit -> BodyInitializer

from workers-types.

Electroid avatar Electroid commented on June 30, 2024

Thanks for calling these out. At the very least, I think it would make sense to provide some type aliases that we mark as @deprecated, and point to the new names.

from workers-types.

lookfirst avatar lookfirst commented on June 30, 2024

Why rename them? They are a worker standard.

Plus, RequestInitializerDict is awful... sounds like a python programmer, or something.

from workers-types.

mrbbot avatar mrbbot commented on June 30, 2024

Hey! 👋 I agree these types shouldn't be renamed as they are standard. There's an internal reason why they're different though. In the runtime source code these types are generated from, RequestInitializerDict is the name of the standard RequestInit interface, whereas RequestInit is actually defined as a type alias to RequestInitializerDict | Request. This get's inlined here:

constructor(input: Request | string, init?: RequestInitializerDict | Request);

It's the same for ResponseInit, BodyInit and HeadersInit as far as I remember. Obviously this isn't ideal. We should either rename the types in the runtime, or add an additional renaming phase to the end of the auto-generation script that fixes these kind of issues.

from workers-types.

vlovich avatar vlovich commented on June 30, 2024

In the latest version we still leak the non-standard names unfortunately. However, as a mitigation I've reintroduced the standard names as aliases to ease porting issues hopefully (#120). Unfortunately it would be annoying to try to figure out how to get rid of those internal names with our automated type generation vs just fixing the name in the runtime.

If you're still having problems, please reopen or file a new issue. Sorry for the churn this may have caused.

from workers-types.

lookfirst avatar lookfirst commented on June 30, 2024

It would be nice if there were unit tests or at least a sample project that depends on the "standard" values so that this doesn't become an issue again.

from workers-types.

vlovich avatar vlovich commented on June 30, 2024

That's a good idea and an area for constant improvement. I'm on the runtime team and was just updating some of the automation pieces and my background is primarily C++/python. I personally unfortunately don't have time/experience to add tests for some of these issues but I'd be happy to review such contributions.

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.