-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Move common type guards into core-util #22872
Move common type guards into core-util #22872
Conversation
A few type guards had duplicate definitions in multiple packages. This change moves the common functions to `core-util`. Fixes Azure#21734
API change check APIView has identified API level changes in this PR and created following API reviews. |
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.
Thanks for taking this work @dgetu! The PR is looking great! The only thing I am not too sure about and would love to see removed from the PR, are the changes under /common
.
Other than that it would be really cool if you can write a few unit tests for the typeguards in core-util. You can take a look at these tests to see how they are setup in core-util
@@ -0,0 +1,10 @@ | |||
{ |
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.
I'm not sure about these changes under common/*. Is it possible to remove these changes?
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.
Done!
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 looks like the rush change
feature that we don't use (but the CADL team does, which is the only reason I know about it.)
sdk/core/core-auth/package.json
Outdated
@@ -63,6 +63,8 @@ | |||
"sideEffects": false, | |||
"dependencies": { | |||
"@azure/abort-controller": "^1.0.0", | |||
"@azure/core-util": "^1.0.1", | |||
"@azure/dev-tool": "^1.0.0", |
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.
Can we remove this dev-tool dependency?
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.
Done!
It may be good to add a Changelog.md entry in @azure/core-util with these changes |
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.
Looks great! Always in favor of deleting duplicate code 😄
I left one minor comment.
sdk/test-utils/recorder/package.json
Outdated
@@ -68,7 +68,7 @@ | |||
"@azure/core-http": "^2.0.0", | |||
"@azure/core-rest-pipeline": "^1.1.0", | |||
"@azure/core-auth": "^1.3.2", | |||
"@azure/core-util": "^1.0.0", | |||
"@azure/core-util": "^1.0.1", |
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.
Is this change necessary?
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.
I think it may be because core-util 1.0.0 doesn't have the new functions so code using it will break if 1.0.0 is installed which meets the ^
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.
Yeah but I don't see the recorder using any of the new stuff.
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.
I added a few unnecessary dependency bumps and missed this one when I reverted them. Fixed!
This reverts commit 7771acb.
… core/move-typeguard-utils-into-core-util
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.
Great stuff! I'm happy to get these consolidated
Seeing some odd build failures in Not sure at all how what changes in the files which looks like just whitespace could have affected this, but since it doesn't appear that there are any |
… core/move-typeguard-utils-into-core-util
… core/move-typeguard-utils-into-core-util
objectHasProperty fails at runtime when it is passed a null or undefined value. This change causes these inputs to instead return false
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.
Looks awesome :) Thanks for the great tests
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.
Love the tests!
import { isDefined, isObjectWithProperties, objectHasProperty } from "../../src/index"; | ||
import { assert } from "chai"; | ||
|
||
describe("Type guards", function () { |
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.
❤️
@dgetu: Should the definitions of https://github.com/Azure/azure-sdk-for-js/search?l=TypeScript&q=%22function+isdefined%22 I'm not sure about |
A few type guards had duplicate identical definitions in multiple packages. This change moves the common functions to
core-util
.Fixes #21734