Restrict types from Uint8Array<ArrayBufferLike> to Uint8Array<ArrayBuffer>#133
Draft
ussu wants to merge 1 commit intocantoo-scribe:masterfrom
Draft
Restrict types from Uint8Array<ArrayBufferLike> to Uint8Array<ArrayBuffer>#133ussu wants to merge 1 commit intocantoo-scribe:masterfrom
ussu wants to merge 1 commit intocantoo-scribe:masterfrom
Conversation
e4509d7 to
6ae67fe
Compare
Sharcoux
requested changes
Feb 17, 2026
src/api/PDFDocument.ts
Outdated
| @@ -1,83 +1,84 @@ | |||
| import { | |||
| parse as parseHtml, | |||
Collaborator
There was a problem hiding this comment.
What is this import rewriting? Can you revert and present only the needed changes?
|
|
||
| import CustomFontEmbedder from './CustomFontEmbedder'; | ||
| import PDFHexString from '../objects/PDFHexString'; | ||
| import { Cache, mergeUint8Arrays, toHexStringOfMinLength } from '../../utils'; |
Collaborator
There was a problem hiding this comment.
Please leave the imports order alone ^^"
| "compilerOptions": { | ||
| /* Basic Options */ | ||
| "target": "es2015", | ||
| "target": "es2024", |
Collaborator
There was a problem hiding this comment.
This is not a trivial change. Let's keep the original target which provides a wider support.
Collaborator
|
Thanks for your contribution. Can you just fix your MR to limit to what is strictly needed to achieve the goal of the PR please? I'll merge after that. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
In Typescript 5.9, there is a more precise typechecking, for instance regarding ArrayBuffer vs SharedArrayBuffer, which are both an ArrayBufferLike
It seems like what pdf-lib uses can always be typed as an ArrayBuffer rather than a SharedArrayBuffer or ArrayBufferLike, so this PR aims to narrow the return types in the package to ArrayBuffer to improve compatibility with other libs
Why?
#132
How?
Updating @types/node to a recent version allows typescript to narrow down most instances of Uint8Array to Uint8Array
In functions exposed by pdf-lib, simply removing the return types explicitly set to Uint8Array ( = Uint8Array) allows typescript to correctly infer the return type to Uint8Array
Testing?
New Dependencies?
no
Screenshots
n/a
Suggested Reading?
Anything Else?
Checklist