chore: Raise TypeScript baseline to 5.9 and adopt generic Uint8Array types. #1208
+33
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the TypeScript baseline to 5.9 for consuming the library. This allows the adoption of the new generic
Uint8Array<TArrayBuffer>
type introduced in that version, improving interoperability with other modern libraries.Rationale
TypeScript 5.9 made some changes to
lib.d.ts
, including the introduction of a generic parameter toUint8Array
:Libraries that interoperate with other frameworks (e.g., Hono) may now expect
Uint8Array<ArrayBuffer>
as a return type. To enable type compatibility without casting, the SDK should reflect this new definition.This change:
as Uint8Array<ArrayBuffer>
boilerplate in downstream consumers.Affected Areas
Uint8Array
are now typed asUint8Array<ArrayBuffer>
. This includes:fastly:secret-store
-SecretStoreEntry.prototype.rawBytes()
fastly:experimental
-includeBytes()
TextEncoder.prototype.encode()
CompressionStream
,DecompressionStream
,Blob
,Body
)fastly:cache-override
- The input and output ofbodyTransformFn
package.json
has been updated to maketypescript
an optional peer dependency, requiring version^5.9.0
if present.SemVer
Strictly speaking under semver, this is a breaking change for consumers using TypeScript < 5.9.
However, in the real TypeScript ecosystem, it appears that this kind of "new compiler baseline" is routinely done in a minor or patch bump, especially when:
peerDependencies
andCHANGELOG
.TypeScript itself did this between 5.8 -> 5.9, and Hono and countless others have done the same in patch/minor bumps.
So I would think that a release including this would be appropriate as the next minor version of
@fastly/js-compute
(i.e., 3.36.0), as it seems to be the de facto convention for TypeScript projects that raising the minimum supported TS version isn't a major bump unless runtime behavior or the emitted JS changes.