From d086f62e5319fb8143d173af713b5306611d9926 Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Thu, 20 Nov 2025 15:45:19 -0500 Subject: [PATCH 1/5] feat: add validate-dts-against-old-typescript task to validate package works when compiled against old typescript versions More context can be found here: https://github.com/livekit/client-sdk-js/pull/1668#pullrequestreview-3289543378 --- .gitignore | 5 ++- package.json | 1 + validate-dts-against-old-typescript.sh | 58 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 validate-dts-against-old-typescript.sh diff --git a/.gitignore b/.gitignore index fa07350e35..1b836bb010 100644 --- a/.gitignore +++ b/.gitignore @@ -113,4 +113,7 @@ pkg/ bin/ examples/**/build/ -.env.local \ No newline at end of file +# dts validation task working directory +dts-validation/ + +.env.local diff --git a/package.json b/package.json index 3fa231d8fb..307914ed68 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "format:check": "prettier --check src examples/**/*.ts", "ci:publish": "pnpm build:clean && pnpm compat && changeset publish", "downlevel-dts": "downlevel-dts ./dist/src ./dist/ts4.2 --to=4.2", + "validate-dts-against-old-typescript": "./validate-dts-against-old-typescript.sh", "compat": "eslint --config ./eslint.config.dist.mjs --no-inline-config ./dist/livekit-client.esm.mjs", "size-limit": "size-limit" }, diff --git a/validate-dts-against-old-typescript.sh b/validate-dts-against-old-typescript.sh new file mode 100755 index 0000000000..b1c26ce734 --- /dev/null +++ b/validate-dts-against-old-typescript.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +TYPESCRIPT_VERSION=${1:-"4.8"} + +echo "# Performing clean build of livekit-client library..." +pnpm build:clean + +echo "# Instantiating dts-validation working directory..." +rm -rf dts-validation +mkdir dts-validation +cd dts-validation + +pnpm init +pnpm install typescript@${TYPESCRIPT_VERSION} +pnpm install ../ + +echo "import 'livekit-client';" > index.ts +cat < tsconfig.json +{ + "compilerOptions": { + "types": ["sdp-transform", "ua-parser-js", "events", "dom-mediacapture-record"], + "target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "ES2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "lib": [ + "DOM", + "DOM.Iterable", + "ES2017", + "ES2018.Promise", + "ES2021.WeakRef" + ], + "rootDir": "./", + "outDir": "dist", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "strict": true /* Enable all strict type-checking options. */, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "skipLibCheck": true /* Skip type checking of declaration files. */, + "noUnusedLocals": true, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, + "moduleResolution": "node", + "resolveJsonModule": true + }, + "include": ["index.ts"] +} +EOF + +echo "# Running tsc against dts-validation working directory..." +npx tsc +result="$?" + +if [[ "${result}" -eq "0" ]]; then + echo "# tsc ran successfully against demo typescript ${TYPESCRIPT_VERSION} project, PASS!" +else + echo "# tsc errored when ran against demo typescript ${TYPESCRIPT_VERSION} project, FAIL!" +fi + +exit ${result} From aedcc8b95a76b319c153bb15374e73fe884a6094 Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Thu, 20 Nov 2025 15:52:57 -0500 Subject: [PATCH 2/5] feat: add github workflow to execute validate-dts-against-old-typescript in parallel --- .../validate-dts-against-old-typescript.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/validate-dts-against-old-typescript.yaml diff --git a/.github/workflows/validate-dts-against-old-typescript.yaml b/.github/workflows/validate-dts-against-old-typescript.yaml new file mode 100644 index 0000000000..ac385ef59c --- /dev/null +++ b/.github/workflows/validate-dts-against-old-typescript.yaml @@ -0,0 +1,23 @@ +name: 'validate-dts-against-old-typescript' +on: + pull_request: + branches: + - main + workflow_dispatch: +jobs: + validate-dts-against-old-typescript: + runs-on: ubuntu-latest + env: + CI_JOB_NUMBER: 1 + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + - name: Use Node.js 24 + uses: actions/setup-node@v6 + with: + node-version: 24 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install + - name: Validates that livekit-client can be parsed in a typescript 4.8 project + run: pnpm validate-dts-against-old-typescript 4.8 From d304e0f71d6826b177fea5706eec8e522575cb94 Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Thu, 20 Nov 2025 15:53:17 -0500 Subject: [PATCH 3/5] docs: add note to top of validate-dts-against-old-typescript script --- validate-dts-against-old-typescript.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/validate-dts-against-old-typescript.sh b/validate-dts-against-old-typescript.sh index b1c26ce734..31b293c2ad 100755 --- a/validate-dts-against-old-typescript.sh +++ b/validate-dts-against-old-typescript.sh @@ -1,4 +1,11 @@ #!/bin/bash +# Runs a check to make sure that a given version of livekit-client can be used in a downstream project +# which is configured with an older version typescript. +# +# In theory, downlevel-dts should handle this, but there has been at least one breaking typing +# change in the past which downlevel-dts has been unable to patch over +# (more info: https://github.com/livekit/client-sdk-js/pull/1668) so this serves as a mechanism to +# catch cases like this in the future before they are reported by users. TYPESCRIPT_VERSION=${1:-"4.8"} From 1c76d7111eaf395874bd3e52cf336ee56d040a3a Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Thu, 20 Nov 2025 15:58:47 -0500 Subject: [PATCH 4/5] fix: add recommended permissions contents read key --- .github/workflows/validate-dts-against-old-typescript.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate-dts-against-old-typescript.yaml b/.github/workflows/validate-dts-against-old-typescript.yaml index ac385ef59c..8604ec13b4 100644 --- a/.github/workflows/validate-dts-against-old-typescript.yaml +++ b/.github/workflows/validate-dts-against-old-typescript.yaml @@ -1,4 +1,6 @@ name: 'validate-dts-against-old-typescript' +permissions: + contents: read on: pull_request: branches: From edb71d3e5fe65e9eb185276ab3e4faf4172aaa0d Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Fri, 21 Nov 2025 17:03:07 -0500 Subject: [PATCH 5/5] fix: make tsconfig uadjustments to get library build errors to show up --- validate-dts-against-old-typescript.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/validate-dts-against-old-typescript.sh b/validate-dts-against-old-typescript.sh index 31b293c2ad..09cd68166a 100755 --- a/validate-dts-against-old-typescript.sh +++ b/validate-dts-against-old-typescript.sh @@ -33,7 +33,10 @@ cat < tsconfig.json "DOM.Iterable", "ES2017", "ES2018.Promise", - "ES2021.WeakRef" + "ES2018.AsyncGenerator", + "ES2020.BigInt", + "ES2021.WeakRef", + "ESNext.AsyncIterable" ], "rootDir": "./", "outDir": "dist", @@ -42,7 +45,7 @@ cat < tsconfig.json "sourceMap": true, "strict": true /* Enable all strict type-checking options. */, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - "skipLibCheck": true /* Skip type checking of declaration files. */, + "skipLibCheck": false /* Skip type checking of declaration files. */, "noUnusedLocals": true, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "moduleResolution": "node",