Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Releases: cloudflare/workers-types

3.3.0

20 Dec 21:22
220b36e
Compare
Choose a tag to compare

What's Changed

  • Adding missing types in RequestInitCfPropertiesImage by @itsmatteomanf in #156
  • Adds env.ASSETS.fetch typings by @GregBrimble in #157
  • Updated types for 2021.12.100 by @autodecl-bot in #165
  • Updated types for 2021.12.300 by @autodecl-bot in #167
  • Updated types for 2021-12-14 by @autodecl-bot in #169
  • 3.3.0 release by @petebacondarwin in #171

New Contributors

Full Changelog: v3.2.0...v3.3.0

3.2.0

17 Nov 12:12
fab42fe
Compare
Choose a tag to compare
  • Add 'error' WebSocket event types overrides [@bretthoerner], [pull/143] & [pull/150]
  • Add PagesFunction type [@GregBrimble], [pull/154]
  • Updated types for 2021.11.400 [@autodecl-bot], [pull/145]
  • Updated types for 2021.11.700 [@autodecl-bot], [pull/149]

3.1.1

02 Nov 17:11
Compare
Choose a tag to compare
  • Add polish key to RequestInitCfProperties - [@threepointone], [pull/131]
  • Added support for gravity: 'auto' to BasicImageTransformations - [@threepointone], [@@jonnedeprez], [pull/132]
  • Fixup DurableObject options names - [@vlovich], [pull/136]
  • Fixes for some crypto APIs - [@vlovich], [pull/137]

3.1.0

02 Nov 09:44
Compare
Choose a tag to compare

Features

  • Updated types for 2021.10.800 - [autodecl-bot], [pull/120]
  • Preserve the @deprecated tag when generating types - [@vlovich], [pull/123]
  • Cleanup unneeded overrides and replace with standard names - [@vlovich], [pull/123]
  • Support merging overrides automatically - [@vlovich], [pull/126]
  • Updated types for 2021.11.0 - [autodecl-bot], [pull/128]

Bugfixes

  • DurableObjectState storage should not be undefined in practice - [@koeninger], [pull/118]
  • Add asOrganization to IncomingRequestCfProperties - [mrkldshv], [pull/111]

3.0.0

19 Oct 13:54
51162f8
Compare
Choose a tag to compare

Features

  • Types are automatically generated from the runtime - @mrbbot, pull/112
    Types now match exactly what's defined in the runtime source code, meaning webworker should be removed from users' tsconfig.jsons

2.1.0

29 Oct 16:03
f778d8b
Compare
Choose a tag to compare

Features

Bugfixes

  • Make Element.attributes iterable - @jdanyow, pull/47

    Fixing a bug in the type definitions that prevents writing valid code like this:

    rewriter.on('bla', {
      element: element => {
        for (const [name, value] of element.attributes) {

Maintenance

  • Update README.md instructions to avoid typescript error - @jeremistadler, pull/60
    Add empty export to bindings.d.ts example to avoid an typescript error

  • Add a GitHub action to lint the Markdown - @jbampton,pull/51

  • Fix spelling - @jbampton,pull/50

  • Add CODEOWNERS - @ispivey, [pull/49]
    This will ensure we have default reviewers.

  • Add prettier and typescript as devDependencies - @1000hz, pull/46
    Automated formatting via prettier

⌨️ 2.0.0

11 Jun 22:48
Compare
Choose a tag to compare

Changelog

⌨️ 2.0.0

Breaking Changes

  • Types now only provided via automatic type inclusion, rather than explicit import - @jdanyow, issue/33, pull/34

    Users should no longer use an empty import to include workers-types, which used to be the recommendation in the README.

    Remove this from your code:

    import {} from '@cloudflare/workers-types'

    And instead include the types explicitly in your TypeScript configuration compiler options:

    {
      "compilerOptions": {
        "types": ["@cloudflare/workers-types"]
      }
    }

Features

  • Add Cache behavior modifiers to outbound Requests - @trjstewart, issue/22, pull/17

    When constructing a request, you can now include the following cache-manipulating properties in the initializer dictionary:

    // Force response to be cached for 300 seconds.
    fetch(event.request, { cf: { cacheTtl: 300 } })
    
    // Force response to be cached for 86400 seconds for 200 status codes, 1 second for 404, and do not cache 500 errors
    fetch(request, { cf: { cacheTtlByStatus: { '200-299': 86400, '404': 1, '500-599': 0 } } })

    Read more about these properties in the Request docs.

  • Add support for caches.default - @ispivey, @ashnewmanjones, issue/8, pull/21

    The Workers runtime exposes a default global cache as caches.default, accessed like:

    let cache = caches.default

    This is an extension to the Service Workers spec for CacheStorage, and thus needed to be added explicitly to our type definitions.

  • Add missing properties to inbound Request cf object - @ispivey, @brycematheson1234, issue/23, pull/24, pull/35

    Adds:

    • clientTcpRtt
    • metroCode
    • botManagement.score
    • botManagement.staticResource
    • botManagement.verifiedBot

    Makes most geolocation properties optional, because they are not guaranteed to be set on every request.

    Changes the type of asn from string to number.

  • Adds cf.cacheKey property to RequestInit - @ispivey, issue/22, pull/28

    Adds the cacheKey property of the cf object to the RequestInit interface.

  • Allow passing another Request as the init arg to Request constructor - @ispivey, issue/15, pull/18

    Previously, this pattern wasn't allowed:

    new Request(parsedUrl.toString(), request)

    This is because the cf object on inbound Request objects, and that expected in the init dictionary arg to the Request constructor, have a different shape.

    This change creates explicit IncomingRequestCfProperties (inbound) and RequestInitCfProperties (outbound) interfaces, and updates the Request constructor to accept either type:

    interface RequestInit {
      cf?: RequestInitCfProperties | IncomingRequestCfProperties
    }

    Read more about the Request constructor in the Request docs.

  • Add CfRequestInit type - @third774, issue/37, pull/44

    Because of the union mentioned above, if an object is declared as RequestInit and sets the cf property, subproperties of cf can not later be reassigned. For this scenario, a more specific CfRequestInit type has been introduced to use instead of RequestInit that doesn't exhibit the same assignability issues.

  • Add iterable methods to FormData, Headers, and URLSearchParams - @ispivey, issue/25, pull/26

    The iterable methods entries(), keys() and values() are not present on these three types in lib.webworker.d.ts. They are instead supplied in lib.dom.iterable.d.ts.

    However, as discussed in this issue on the TypeScript repo, lib.dom.d.ts and lib.webworker.d.ts have conflicting type definitions, and the maintainers hope to solve this issue by refactoring shared components into a new web.iterable.d.ts lib: microsoft/TypeScript#32435 (comment)

    Until then, we will include the iterable methods supported by Workers in our own type definitions.

Bugfixes

  • Remove selector parameter from onDocument() - @jdanyow, pull/41

    The type signature for HTMLRewriter's onDocument() method previously erroneously included a selector parameter as its first argument. This has been removed.

  • Make KVNamespace.list() options argument optional - @motiejunas, pull/10

    Previously, the KVNamespace interface required that callers provide an empty options object when listing all the keys in a namespace, like so:

    await NAMESPACE.list({})

    However, this argument is not actually required. This change updates the interface to match the runtime.

Maintenance

  • Add a Release Checklist - @ispivey, issue/20, pull/27

    As we onboard more contributors, we're documenting release procedures.

  • Add BSD-3 License - @ispivey, issue/31, pull/30, pull/40

    As we transition this to a project supported by the Cloudflare Workers team, we're releasing the code under a BSD-3 license. Thanks to all the contributors for their help!