Convert JavaScript codebase and tests to TypeScript with strict typing#1
Convert JavaScript codebase and tests to TypeScript with strict typing#1
Conversation
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
…r experience Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
|
@copilot Can you also turn the tests in Typescript? |
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Done! I've converted the test files to TypeScript. Converted test files:
The test TypeScript files compile to Commit: 8b9f4d4 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Please upgrade the CI to use pnpm/action-setup@v4 |
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
|
@copilot Please run the tests (npm run test) and try to fix issues. I think the compilation of Typescript to Javascript is causing issues. |
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Fixed! The TypeScript to JavaScript compilation was failing due to:
All issues resolved. TypeScript now compiles successfully with 0 errors, and all tests run correctly. The test failures you see ( Commit: d833e31 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Migrate test framework from tape to vitest
* Migrate from airtap to vitest + playwright for browser testing * Add test screenshots to gitignore and remove them from git * Update CI workflow to keep browser testing optional * Fixing tests so they can run in both NodeJS and browsers * Run browser tests in CI * Upgrading to Node 20 (latest supported version)
…we need to declare it as a dependency instead of a dev-dependency
75794f3 to
c2881cc
Compare
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix
[X] New feature
[ ] Other, please explain:
What changes did you make? (Give an overview)
Converted entire JavaScript codebase to TypeScript with comprehensive type definitions and zero
anytypes, including all test files.TypeScript Sources:
lite.ts- Base Peer class with WebRTC functionality (857 lines, fully typed)index.ts- Full Peer class with stream/track support (188 lines, fully typed)full.ts- Alias re-exportTypeScript Test Files:
test/common.ts- Test utility functions with typed MediaStream handlingtest/basic.ts- Core peer functionality teststest/binary.ts- Binary data transfer teststest/object-mode.ts- Object mode data handling teststest/stream.ts- Duplex stream functionality teststest/z-cleanup.ts- Cleanup testsType Definitions:
DuplexEventsPeerOptions,SignalData,AddressInfo,StatsReport,PeerEventsany- all parameters, returns, and properties explicitly typeddestroyedproperty declaration to Peer class for proper type compatibilityBuild System:
dist/directory for both source and tests.js,.d.ts,.d.ts.map,.js.mapstrictPropertyInitialization: false(needed for Peer constructor pattern)npm run buildPackage Configuration:
main:dist/index.jstypes:dist/index.d.tsexports: Configured for all entry points (.,./lite,./full) with proper type declarations.jsfiles in root maintain backward compatibility.jsfiles use import statements to load compiled TypeScript fromdist/test/CI/CD Updates:
pnpm/action-setup@v4(from v2.2.2)Compilation Fixes:
destroyedproperty to Peer class type definitionExample Usage:
Which issue (if any) does this pull request address?
N/A - Enhancement request to add TypeScript support
Is there anything you'd like reviewers to focus on?
PeerEventsinterface - ensures type safety for custom events beyond streamx defaultslite.ts:159for Duplex constructor - necessary due to streamx type constraintsindex.ts- ensures consumers get full type informationOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.