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

Fix integration tests type errors on bindgen #5479

Closed
wants to merge 469 commits into from
Closed

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Feb 22, 2023

What, How & Why?

Fixes all type errors in our integration tests pre-test migration.

This closes #5486

☑️ ToDos

  • 💥 Breaking label has been applied or is not necessary

@cla-bot cla-bot bot added the cla: yes label Feb 23, 2023
@@ -24,7 +24,7 @@ export interface IPerson {
_id: Realm.BSON.ObjectId;
name: string;
age: number;
friends: Realm.List<IPerson>;
friends: Realm.List<Person>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing this as a quickfix for now... pending our discussions regarding this

@gagik gagik marked this pull request as ready for review February 23, 2023 10:19
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
"outDir": "dist",
"lib": [
"es2018"
"es2020"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes:

../../node_modules/@thi.ng/api/typedarray.d.ts:112:10 - error TS2583: Cannot find name 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later.

Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

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

Looks good! We might want to bring some of those open questions up in the group.
And I'm sure there will also be a lot more of this type of work once the migrated tests land in bindgen. Might be a good opportunity to implement whatever is the answer to said open questions.

integration-tests/tests/src/tests/sync/asymmetric.ts Outdated Show resolved Hide resolved
@@ -822,7 +822,7 @@ export class Realm {
/**
* Deletes the provided Realm object, or each one inside the provided collection.
*/
delete(subject: RealmObject | RealmObject[] | List | Results): void {
delete<T = DefaultObject>(subject: RealmObject<T> | RealmObject<T>[] | List<T> | Results<T>): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs an overloaded definition to better depict these types, similar to create above. I don't think any is the answer

@@ -27,6 +27,8 @@ import * as bson from "bson";
export namespace BSON {
export const ObjectId = bson.ObjectId;
export type ObjectId = bson.ObjectId;
export const ObjectID = bson.ObjectID;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wish it didn't exist, but we might not have a choice.

Copy link
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

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

Awesome, it's going to be really nice with these type errors gone!

integration-tests/tests/src/tests/queries.ts Show resolved Hide resolved
integration-tests/tests/src/tests/sync/asymmetric.ts Outdated Show resolved Hide resolved
Comment on lines +1393 to +1394
// TODO: should this not support removeByObjectType(Dog)?
expect(mutableSubs.removeByObjectType(Dog.schema.name)).to.equal(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

The API currently only exposes a method taking a string ☝️ But having an overload accepting e.g. Dog could probably be helpful (as long as the name retrieved will be the same value specified on the name property of the schema).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have this functionality with i.e. create so I do think this should be possible

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it could provide a nicer consistency with both create and objects :)

@@ -822,7 +822,7 @@ export class Realm {
/**
* Deletes the provided Realm object, or each one inside the provided collection.
*/
delete(subject: RealmObject | RealmObject[] | List | Results): void {
delete<T = DefaultObject>(subject: RealmObject<T> | RealmObject<T>[] | List<T> | Results<T>): void {
Copy link
Contributor

@elle-j elle-j Feb 24, 2023

Choose a reason for hiding this comment

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

Another question, does this method need an overload that takes the generic arg T extends RealmObject?

(Update: Saw that @takameyer mentioned this ☝️ , I believe we're referring to the same thing)

Copy link
Contributor

@kneth kneth left a comment

Choose a reason for hiding this comment

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

Nice clean up!

Copy link
Contributor

@JacobOscarGunnarsson JacobOscarGunnarsson left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from bindgen to master March 3, 2023 14:05
@papafe
Copy link
Contributor

papafe commented Apr 19, 2023

@realm/realm-js-team what should we do with this PR?

@takameyer takameyer self-assigned this Jul 12, 2023
@kneth
Copy link
Contributor

kneth commented May 31, 2024

It will be complicated to rebase this branch so I am closing the PR

@kneth kneth closed this May 31, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix integration test type errors
8 participants