Skip to content

Conversation

@lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Oct 1, 2025

closes #1661

So far we’ve kept pretty much up to date with TS versions and used downlevel-dts to transpile any non compatible TS constructs down for older versions. This CLI tool hasn't been updated in a while though, so this particular issue at hand is not part of the fixes it supports.

When a Uint8Array like type is inferred directly from usage within a TS >5.7 project (like this one) then the emitted d.ts will use something like Uint8Array<ArrayBuffer> which is incompatible with older TS versions.

The options we have is

  • explicitly declare Uint8Array as return type (or declared type)
  • use a type helper for all Uint8Array usage that looks like ReturnType<Uint8Array.from>
  • write a babel plugin that transforms it

I opted for the explicit declaration for now.

full context: microsoft/TypeScript#62240

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: d0f4ff4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 81.64 KB (0%)
dist/livekit-client.umd.js 87.69 KB (0%)

"format:check": "prettier --check src examples/**/*.ts",
"ci:publish": "pnpm build:clean && pnpm compat && changeset publish",
"downlevel-dts": "downlevel-dts ./dist/ ./dist/ts4.2 --to=4.2",
"downlevel-dts": "downlevel-dts ./dist/src ./dist/ts4.2 --to=4.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive by fix that ensures we really only downlevel the emitted d.ts files in the dist/src folder where the original source types are emitted to.

@lukasIO lukasIO requested a review from 1egoman October 1, 2025 07:45
Copy link
Contributor

@1egoman 1egoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's here makes sense to me!

That being said, as is this change doesn't do anything to prevent this from happening in the future, to me it seems like without some guardrails, this will inevitably regress.

I realize this might be a bit of a tedious ask, but maybe it would be worth adding to CI something like:

  1. Build the library normally.
  2. Install the oldest supported typescript version.
  3. Use that oldest supported typescript version to build a script containing something like import 'livekit-client'.
  4. If step 3 it returns a non-zero code, fail the CI run.

Thoughts on that?

@lukasIO
Copy link
Contributor Author

lukasIO commented Oct 1, 2025

Yeah, I like the suggestion of an additional CI test.

Just realised that the issue is not actually about 5.9 (which raises some build errors also internally for us) but is likely due to the changes in TS 5.7 when the Uint8Array was first made generic. I'll update the description to reflect that

@lukasIO lukasIO changed the title Fix TS 5.9 generic Uint8Array declaration when inferred Fix TS 5.7 generic Uint8Array declaration when inferred Oct 1, 2025
@lukasIO lukasIO merged commit 84b1a6f into main Oct 1, 2025
6 checks passed
@lukasIO lukasIO deleted the lukas/fix-ts-incompat branch October 1, 2025 15:31
1egoman added a commit that referenced this pull request Nov 20, 2025
…e works when compiled against old typescript versions

More context can be found here: #1668 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript error: 'Uint8Array' is not generic in LocalTrack.d.ts (Angular 18 / TS 5.4)

3 participants