Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/validate-dts-against-old-typescript.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'validate-dts-against-old-typescript'
permissions:
contents: read
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ pkg/
bin/
examples/**/build/

.env.local
# dts validation task working directory
dts-validation/

.env.local
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
68 changes: 68 additions & 0 deletions validate-dts-against-old-typescript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/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"}

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 <<EOF > 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",
"ES2018.AsyncGenerator",
"ES2020.BigInt",
"ES2021.WeakRef",
"ESNext.AsyncIterable"
],
"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": false /* 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}
Loading