-
Notifications
You must be signed in to change notification settings - Fork 168
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
Improve type safety with noImplicitAny
#1052
Conversation
@@ -29,30 +28,39 @@ export function getQueries( | |||
|
|||
queries.push({ | |||
document, | |||
source: document?.loc?.source, |
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 is not used when getting the query string, so I opted to remove this to avoid confusion on whether this is used.
@@ -64,7 +72,6 @@ export function getMutations(mutationsObj): QueryInfo[] { | |||
return { | |||
document: mutation, | |||
variables, | |||
source: mutation?.loc?.source, |
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.
Previously this source
was used to print the mutationString
, but was inconsistent with the way queries were printed, which just used the print
function from graphql
on the document
. For consistency, this was updated to do the same.
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.
Some small nitpicks, but also a big THANK YOU!
@@ -55,7 +68,7 @@ export function EntityView({ cacheId, data, searchResults, setCacheId }) { | |||
`} | |||
onClick={() => { | |||
if (key === "__ref") { | |||
setCacheId(value); | |||
setCacheId(value as string); |
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.
May I suggest just converting it to a string if it's unknown
?
setCacheId(value as string); | |
setCacheId(String(value)); |
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 should always be a Refererence
object which would guarantee a string here, but not opposed either.
@@ -60,7 +60,7 @@ export const handleAuthenticationPostMessage = ({ | |||
"apolloStudioEmbeddedExplorerEncodedApiKey" |
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.
Maybe the full
const partialEmbedApiKeysString = window.localStorage.getItem(
"apolloStudioEmbeddedExplorerEncodedApiKey"
);
const partialEmbedApiKeys = partialEmbedApiKeysString
? (JSON.parse(partialEmbedApiKeysString) as Record<string, string>)
: {};
block could be extracted into a helper function? It repeats three times.
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 noticed that too. I'll go back through in a separate PR and do a few more refactorings like this 🙂
Co-authored-by: Lenz Weber-Tronic <mail@lenzw.de>
Partially addresses #1047
Enables the
noImplicitAny
TS rule and fixes all the TS errors as a result. In addition to the fixes, I provided a few improvements:ts-reset
to fix some edge case weirdnessQueries
andMutations
views that avoids the need for 2 queries and instead uses a plainarray.find(...)
to get the selected query.