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

[converter] Avoid spying on properties of the 'tfOps' module #6563

Merged

Conversation

mattsoulanille
Copy link
Member

@mattsoulanille mattsoulanille commented Jun 23, 2022

According to the ESModule standard, properties of modules are immutable. TypeScript 4 will enforce this rule. This in particular affects tests for executors in tfjs-converter, in which we often spy on tfOps.

This PR removes all instances of spyOn(tfOps,...) and replaces them with a separate spyOps mock / fake which is passed to the executeOp function.

It also removes spying on the io module in graph_model_test.ts.

This PR was part of the larger TS4 upgrade PR (#6346, #5561), but I'm splitting that PR into pieces that can be merged while we're still using TS3 because it's too large to keep up-to-date.

This PR also bumps lib to es2019 in the root tsconfig to allow using Object.fromEntries. This shouldn't affect the code we ship since it's still compiled to the es2017 target.

Note that this PR does not bump TypeScript to version 4. It leaves it at 3.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

According to the ESModules standard, code can not modify properties of modules. TypeScript 4 will enforce this rule. This in particular affects tests for executors in tfjs-converter, in which we often spy on tfOps.

This PR removes all instances of `spyOn(tfOps,...)` and replaces them with a separate `spyOps` mock / fake which is passed to the `executeOp` function.

This PR was part of the larger TS4 upgrade PR (tensorflow#6346), but I'm splitting that PR into pieces that can be merged while we're still using TS3 because it's too large to keep up-to-date.
@mattsoulanille
Copy link
Member Author

@pyu10055 These changes should be nearly identical to the ones in #5561, which you've already reviewed.

@mattsoulanille mattsoulanille requested review from lina128 and Linchenn and removed request for jinjingforever and lina128 June 27, 2022 19:31
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Reviewed 1 of 1 files at r1, 44 of 44 files at r2, 3 of 3 files at r3, 1 of 1 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @Linchenn)

@mattsoulanille mattsoulanille merged commit ccca854 into tensorflow:master Jun 29, 2022
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.

3 participants