-
Add types for Durable Objects - @mathew-cf, pull/63, issue/64 Types for Durable Objects Beta, subject to change.
-
Add ScheduledEvent - @qwtel, pull/61 Types for Scheduled Events
-
Add AVIF Format for Image Resizing - @GregBrimble, pull/59
-
Add metadata typings for KV - @GregBrimble, pull/54 Adds the new metadata types to the getWithMetadata, put and list methods on a KV namespace.
-
Complete Image Resizing properties - @GregBrimble, pull/50 Adds missing options for the Image Resizing API.
-
Add API for async handlers and end handler - @ObsidianMinor, pull/48 Types for HTML Rewriter end of document append method
-
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) {
-
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
-
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
-
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"] } }
-
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
Requestdocs. -
Add support for
caches.default- @ispivey, @ashnewmanjones, issue/8, pull/21The 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
Requestcfobject - @ispivey, @brycematheson1234, issue/23, pull/24, pull/35Adds:
clientTcpRttmetroCodebotManagement.scorebotManagement.staticResourcebotManagement.verifiedBot
Makes most geolocation properties optional, because they are not guaranteed to be set on every request.
Changes the type of
asnfrom string to number. -
Adds
cf.cacheKeyproperty toRequestInit- @ispivey, issue/22, pull/28Adds the
cacheKeyproperty of thecfobject to theRequestInitinterface. -
Allow passing another Request as the
initarg toRequestconstructor - @ispivey, issue/15, pull/18Previously, this pattern wasn't allowed:
new Request(parsedUrl.toString(), request)
This is because the
cfobject on inbound Request objects, and that expected in theinitdictionary arg to the Request constructor, have a different shape.This change creates explicit
IncomingRequestCfProperties(inbound) andRequestInitCfProperties(outbound) interfaces, and updates theRequestconstructor to accept either type:interface RequestInit { cf?: RequestInitCfProperties | IncomingRequestCfProperties }
Read more about the
Requestconstructor in theRequestdocs. -
Add
CfRequestInittype - @third774, issue/37, pull/44Because of the union mentioned above, if an object is declared as
RequestInitand sets thecfproperty, subproperties ofcfcan not later be reassigned. For this scenario, a more specificCfRequestInittype has been introduced to use instead ofRequestInitthat doesn't exhibit the same assignability issues. -
Add iterable methods to
FormData,Headers, andURLSearchParams- @ispivey, issue/25, pull/26The iterable methods
entries(),keys()andvalues()are not present on these three types inlib.webworker.d.ts. They are instead supplied inlib.dom.iterable.d.ts.However, as discussed in this issue on the TypeScript repo,
lib.dom.d.tsandlib.webworker.d.tshave conflicting type definitions, and the maintainers hope to solve this issue by refactoring shared components into a newweb.iterable.d.tslib: microsoft/TypeScript#32435 (comment)Until then, we will include the iterable methods supported by Workers in our own type definitions.
-
Remove
selectorparameter fromonDocument()- @jdanyow, pull/41The type signature for HTMLRewriter's
onDocument()method previously erroneously included aselectorparameter as its first argument. This has been removed. -
Make
KVNamespace.list()options argument optional - @motiejunas, pull/10Previously, the
KVNamespaceinterface 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.
-
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!