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

Switch long bigint #333

Merged
merged 10 commits into from
Apr 6, 2023
Merged

Switch long bigint #333

merged 10 commits into from
Apr 6, 2023

Conversation

Zetazzz
Copy link
Collaborator

@Zetazzz Zetazzz commented Apr 3, 2023

add a flag to switch Long or bigint
handle all cases switching between Long or bigint
also to switch helper.ts between Long or bigint

@Zetazzz Zetazzz closed this Apr 3, 2023
@Zetazzz Zetazzz reopened this Apr 3, 2023
}

/** DeploymentID stores owner and sequence number */
export interface DeploymentIDSDKType {
owner: string;
dseq: Long;
dseq: bigint;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be BigInt with caps included?

Copy link
Collaborator Author

@Zetazzz Zetazzz Apr 4, 2023

Choose a reason for hiding this comment

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

Hi, I think bigint here is the way to use it as a basic type. For BigInt, it's more like a constructor for bigint. So for me I prefer bigint.

And also, In fact at the beginning I used BigInt here, but my local compiler told me when I was doing arithmetic operations using it with other bigint types:

The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ts(2362)
Operator '*' cannot be applied to types 'BigInt' and 'bigint'. ts(2365)

So that's also why I changed it into bigint.

@@ -177,7 +177,7 @@ export const Group = {
message.groupId = object.groupId !== undefined && object.groupId !== null ? GroupID.fromPartial(object.groupId) : undefined;
message.state = object.state ?? 0;
message.groupSpec = object.groupSpec !== undefined && object.groupSpec !== null ? GroupSpec.fromPartial(object.groupSpec) : undefined;
message.createdAt = object.createdAt !== undefined && object.createdAt !== null ? Long.fromValue(object.createdAt) : Long.ZERO;
message.createdAt = object.createdAt !== undefined && object.createdAt !== null ? (prop => BigInt(prop.toString!!()))(object.createdAt) : BigInt("0");
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the idea behind using an executed anonymous function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah... I just thought it as a bigint version of Long.fromValue (without applying toString to the property itself). After thinking this again, i'll change it to a decent way of doing this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done removing.

@Zetazzz Zetazzz merged commit c155fb8 into cosmology-tech:main Apr 6, 2023
@Zetazzz Zetazzz linked an issue May 23, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long.fromValue causing overflow
2 participants