Skip to content
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

Fixes missing / incorrect TypeScript descriptions. #668

Merged
merged 1 commit into from
Aug 10, 2023
Merged
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
14 changes: 7 additions & 7 deletions src/numbers/sc_int.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ import { XdrLargeInt } from './xdr_large_int';
* // Or reinterpret it as a different type (size permitting):
* const scv = i.toI64();
*
* @param {number|bigint|string|ScInt} value - a single, integer-like value
* which will be interpreted in the smallest appropriate XDR type supported
* by Stellar (64, 128, or 256 bit integer values). signed values are
* supported, though they are sanity-checked against `opts.type`. if you need
* 32-bit values, you can construct them directly without needing this
* wrapper, e.g. `xdr.ScVal.scvU32(1234)`.
* @param {number|bigint|string} value - a single, integer-like value which will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for consideration, to assert these value types only are allowed, another unit test like 'it throws when invalid value' in scint_test.js with StellarBase.ScInt({}), would sweep up coverage for not allowing ScInt anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more like the jsdoc was wrong - ScInt was never actually supported

* be interpreted in the smallest appropriate XDR type supported by Stellar
* (64, 128, or 256 bit integer values). signed values are supported, though
* they are sanity-checked against `opts.type`. if you need 32-bit values,
* you can construct them directly without needing this wrapper, e.g.
* `xdr.ScVal.scvU32(1234)`.
*
* @param {object} [opts] - an optional object controlling optional parameters
* @param {string} [opts.type] - force a specific data type. the type choices
Expand Down Expand Up @@ -96,7 +96,7 @@ export class ScInt extends XdrLargeInt {

default:
throw RangeError(
`expected 64/128/256 bits for parts (${value}), got ${bitlen}`
`expected 64/128/256 bits for input (${value}), got ${bitlen}`
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ export class XdrLargeInt {
toU128(): xdr.ScVal;
toI256(): xdr.ScVal;
toU256(): xdr.ScVal;
toScVal(): xdr.ScVal;

valueOf(): any; // FIXME
toString(): string;
Expand All @@ -1115,7 +1116,7 @@ export class XdrLargeInt {
}

export class ScInt extends XdrLargeInt {
constructor(value: IntLike | ScInt, opts?: { type: ScIntType });
constructor(value: IntLike, opts?: { type: ScIntType });
}

export function scValToBigInt(scv: xdr.ScVal): bigint;
Expand Down
Loading