Use mockedObject for TreeView#2768
Merged
robertbrignull merged 1 commit intomainfrom Sep 1, 2023
Merged
Conversation
3 tasks
charisk
approved these changes
Sep 1, 2023
Contributor
charisk
left a comment
There was a problem hiding this comment.
Thanks! I think this is an improvement so we should go ahead with it.
I also think that it's not out of the question to provide some functions to mock TreeView objects if we wanted to, but that's something for another day.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is one possible solution to the conversation from https://github.com/github/vscode-codeql/pull/2735/files#r1303916205.
Effectively this is still using
as unknown as Xbut at least that's now contained withinmockedObjectwhich mocks all other fields and methods and throws a helpful error message when code tries to use them.I think using
mockedObjectfor theTreeViewtype makes sense. It's a hard type to provide a "real" instance of, because:Also importantly, we don't ever do type checking on this type, so fields being mocked doesn't cause problems with this. In the linked PR I objected to using
mockedObjectfor theExternalApiUsageandUsagetypes because we have theisExternalApiUsagemethod and therefore the actual fields at runtime matter and not just appeasing the typescript type system.Checklist
ready-for-doc-reviewlabel there.