Skip to content
Open
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
22 changes: 21 additions & 1 deletion .github/workflows/ci-socket.io-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 'packages/socket.io-client/**'
- 'packages/socket.io-component-emitter/**'
- 'packages/socket.io-parser/**'
- 'examples/typescript-check-public-exports/**'
- '.github/workflows/ci-socket.io-client.yml'
pull_request:
paths:
Expand All @@ -24,6 +25,7 @@ on:
- 'packages/socket.io-client/**'
- 'packages/socket.io-component-emitter/**'
- 'packages/socket.io-parser/**'
- 'examples/typescript-check-public-exports/**'
- '.github/workflows/ci-socket.io-client.yml'

permissions:
Expand Down Expand Up @@ -57,6 +59,9 @@ jobs:
- name: Compile package
run: npm run compile --workspace=socket.io-client

- name: Check public type declarations
run: npm run test:types --workspace=socket.io-client

- name: Compile dev dependencies
run: |
npm run compile \
Expand All @@ -67,8 +72,23 @@ jobs:
- name: Run tests
run: npm test --workspace=socket.io-client

- name: Run browser tests
- name: Check browser test credentials
if: github.event_name == 'push'
id: browser-tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: |
if [ -n "$SAUCE_USERNAME" ] && [ -n "$SAUCE_ACCESS_KEY" ]; then
echo "enabled=true" >> "$GITHUB_OUTPUT"
else
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::notice::Skipping Sauce Labs browser tests: credentials are not configured."
echo "Browser tests skipped because Sauce Labs credentials are not configured. Browser coverage has not been verified." >> "$GITHUB_STEP_SUMMARY"
fi

- name: Run browser tests
if: github.event_name == 'push' && steps.browser-tests.outputs.enabled == 'true'
run: npm test --workspace=socket.io-client
env:
BROWSERS: 1
Expand Down
9 changes: 9 additions & 0 deletions examples/typescript-check-public-exports/mapped-socket.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { io } from "socket.io-client";

// Reactive stores expose the public properties of a Socket through mapped types.
// Declaration emit must be able to name the types used by those properties.
function publicProperties<T>(value: T): { [K in keyof T]: T[K] } {
return value;
}

export const socket = publicProperties(io({ autoConnect: false }));
3 changes: 2 additions & 1 deletion examples/typescript-check-public-exports/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"noEmit": true,
"emitDeclarationOnly": true,
"outDir": "./dist",

// Stricter Typechecking Options
"noUncheckedIndexedAccess": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/socket.io-client/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { url } from "./url.js";
import { Manager, ManagerOptions, ManagerReservedEvents } from "./manager.js";
import {
DecorateAcknowledgements,
DisconnectDescription,
ExtendedError,
Socket,
Expand Down Expand Up @@ -97,6 +98,7 @@ export { protocol } from "socket.io-parser";
*/

export {
DecorateAcknowledgements,
DisconnectDescription,
ExtendedError,
Manager,
Expand Down
2 changes: 1 addition & 1 deletion packages/socket.io-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
"test:node": "mocha --import=tsx --require test/support/hooks.ts --exit test/index.ts",
"test:browser": "ts-node test/browser-runner.ts",
"test:types": "exit 0",
"test:types": "tsc -p ../../examples/typescript-check-public-exports",
"build": "rollup -c support/rollup.config.umd.js && rollup -c support/rollup.config.esm.js && rollup -c support/rollup.config.umd.msgpack.js",
"bundle-size": "node support/bundle-size.js",
"format:check": "prettier --check \"*.js\" \"lib/**/*.ts\" \"test/**/*.ts\" \"support/**/*.js\"",
Expand Down