-
Notifications
You must be signed in to change notification settings - Fork 142
Finish util migration #851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: typescript-migration
Are you sure you want to change the base?
Conversation
Ryang-21
commented
Feb 10, 2026
- Migrates the rest of the util files
- Converted javascript testing to typescript
- Added unit testing on previously untested functions
| import xdr from "../xdr.js"; | ||
| /** | ||
| * Converts a Stellar address (in G... or M... form) to an `xdr.MuxedAccount` | ||
| * structure, using the ed25519 representation when possible. | ||
| * | ||
| * This supports full muxed accounts, where an `M...` address will resolve to | ||
| * both its underlying `G...` address and an integer ID. | ||
| * | ||
| * @param address G... or M... address to encode into XDR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only this file is contained in the manually written type declarations
|
Size Change: +5.2 kB (+0.15%) Total Size: 3.51 MB
|
| @@ -0,0 +1,38 @@ | |||
| export class StrKey { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary and will be removed once the Strkey src file has been migrated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR continues the util-to-TypeScript migration, adds/updates declaration files, and ports several util unit tests from the older JS/Mocha style to TypeScript/Vitest.
Changes:
- Added/updated TypeScript sources and declaration outputs for util helpers and XDR re-exports.
- Added new Vitest-based TypeScript unit tests for util modules (and removed the old JS test).
- Added generated XDR
.d.tslink files and updated formatting/config docs (changelog + prettier ignore).
Reviewed changes
Copilot reviewed 14 out of 22 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| type_validation/xdr.d.ts | Adds declaration output for xdr re-export (currently has unresolved import path in type_validation). |
| type_validation/util/util.d.ts | Adds trimEnd declaration (return type could better preserve input/output relationship). |
| type_validation/util/decode_encode_muxed_account.d.ts | Adds declarations for muxed account helpers (currently imports a non-existent ../xdr.js within type_validation). |
| type_validation/util/continued_fraction.d.ts | Adds best_r declaration (missing BigNumber import/type). |
| type_validation/util/bignumber.d.ts | Adds BigNumber declaration (currently relies on globalThis.BigNumber, likely incorrect). |
| test/unit/util/util.test.ts | Adds Vitest coverage for trimEnd (imports .js specifier that likely won’t resolve to .ts in Vitest). |
| test/unit/util/decode_encode_muxed_account.test.ts | Adds Vitest coverage for muxed account helpers (imports .js specifiers including removed src/xdr.js). |
| test/unit/util/continued_fraction.test.ts | Ports continued fraction tests to Vitest (imports .js specifier likely not resolvable). |
| test/unit/util/checksum.test.ts | Updates checksum test import to .js (likely not resolvable by Vitest without extension aliasing). |
| test/unit/util/bignumber_test.js | Removes legacy JS test. |
| test/unit/util/bignumber.test.ts | Adds Vitest TS replacement test (imports .js specifier likely not resolvable). |
| src/xdr.ts | Introduces TS xdr entry point; removal of src/xdr.js requires consistent resolver/shim behavior across toolchains. |
| src/xdr.js | Removes previous JS xdr entry point. |
| src/util/util.ts | Adds TS types to trimEnd signature (could use overloads/generic for better typing). |
| src/util/decode_encode_muxed_account.ts | Adds TS annotations + .js-style specifiers for TS/ESM compatibility. |
| src/util/continued_fraction.ts | Adds TS annotations and safer indexing (but BigNumber typing needs correction). |
| src/util/bignumber.ts | Attempts to export a BigNumber type but currently does so incorrectly. |
| src/strkey.d.ts | Adds StrKey type declarations. |
| src/generated/next_generated.d.ts | Links generated JS XDR to types/next typings. |
| src/generated/curr_generated.d.ts | Links generated JS XDR to types/curr typings. |
| config/.prettierignore | Ignores CHANGELOG.md. |
| CHANGELOG.md | Documents a breaking type change, but published types still appear to include supportMuxing. |
Comments suppressed due to low confidence (4)
test/unit/util/continued_fraction.test.ts:2
- This Vitest test imports
best_rfromsrc/util/continued_fraction.js, but the source file issrc/util/continued_fraction.ts(no.jsfile insrc). Unless Vitest is configured to resolve.jsspecifiers to.ts, this will fail with module-not-found. Update the test import approach or add a resolver to Vitest/Vite similar to the webpackextensionAliassetup.
src/util/continued_fraction.ts:14 rawNumber: BigNumber | number | stringis using the importedBigNumbervalue as a type. That refers to the constructor type (or will error) rather than a BigNumber instance/value type accepted by the constructor. Use an explicit BigNumber instance/value type (e.g.,BigNumber.Valuefrombignumber.jstypes, orInstanceType<typeof BigNumber>), and ensure the exported BigNumber types from./bignumber.jsare correct.
src/util/util.ts:4trimEnd’s signature returnsnumber | string, which loses the relationship between input and output types (even though the implementation returns the same kind as the input). Consider using overloads or a generic (<T extends number | string>(input: T, ...) => T) so TypeScript callers don’t need casts and get accurate return typing.
src/util/bignumber.ts:8export type { BigNumber };is exporting a type from a value-onlyconst BigNumber(the cloned constructor). This is not a valid type export and will fail TypeScript compilation. Define and export an explicit type alias (e.g., for the instance or constructor) or re-export the appropriate type frombignumber.js, then use that in other modules.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
987facb to
0b16894
Compare
88ed639 to
ee15c39
Compare
This reverts commit ddb94f2.
731ad2b to
5046632
Compare