-
Notifications
You must be signed in to change notification settings - Fork 17
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: Add noUncheckedIndexAccess to tsconfig #281
Changes from 6 commits
18d9bbd
d25812f
effaf1e
029cef2
9f8ec88
c82d198
d89d8ee
a5c4d33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,9 +343,12 @@ function readData<TReadFromStore>( | |
} else { | ||
const refetchQueryIndex = field.refetchQuery; | ||
if (refetchQueryIndex == null) { | ||
throw new Error('refetchQuery is null in RefetchField'); | ||
throw new Error('refetchQueryIndex is null in RefetchField'); | ||
} | ||
const refetchQuery = nestedRefetchQueries[refetchQueryIndex]; | ||
if (refetchQuery == null) { | ||
throw new Error('refetchQuery is null in RefetchField'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add that this is indicative of a bug in Isograph There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
} | ||
const refetchQueryArtifact = refetchQuery.artifact; | ||
const allowedVariables = refetchQuery.allowedVariables; | ||
|
||
|
@@ -371,9 +374,13 @@ function readData<TReadFromStore>( | |
} | ||
case 'Resolver': { | ||
const usedRefetchQueries = field.usedRefetchQueries; | ||
const resolverRefetchQueries = usedRefetchQueries.map( | ||
(index) => nestedRefetchQueries[index], | ||
); | ||
const resolverRefetchQueries = usedRefetchQueries.map((index) => { | ||
const resolverRefetchQuery = nestedRefetchQueries[index]; | ||
if (resolverRefetchQuery == null) { | ||
throw new Error('resolverRefetchQuery is null in Resolver'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
} | ||
return resolverRefetchQuery; | ||
}); | ||
|
||
switch (field.readerArtifact.kind) { | ||
case 'EagerReaderArtifact': { | ||
|
@@ -636,7 +643,11 @@ function generateChildVariableMap( | |
const childVars: Writable<Variables> = {}; | ||
for (const [name, value] of fieldArguments) { | ||
if (value.kind === 'Variable') { | ||
childVars[name] = variables[value.name]; | ||
const variable = variables[value.name]; | ||
if (variable == null) { | ||
throw new Error('Variable ' + value.name + ' is not missing'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/not missing/missing But also, this breaks if we have a default value for a variable and the variable is not provided, e.g. I think the appropriate behavior is to continue the loop, i.e. we don't (currently) distinguish between missing and null variables, so skipping the variable is appropriate (and based on my limited testing, works) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ChatGPT, thank you for being awful lol. I did not even see the "not" lol And that logic makes sense! Will just allow the loop to continue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
} | ||
childVars[name] = variable; | ||
} else { | ||
childVars[name] = value.value; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,8 +114,13 @@ export function useConnectionSpecPagination< | |
fragmentReference.readerWithRefetchQueries, | ||
); | ||
|
||
const data = readOutDataAndRecords[i]?.item; | ||
if (data == null) { | ||
throw new Error('Parameter data is unexpectedly null'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indicative of a bug in isograph, likewise below and in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
} | ||
|
||
const firstParameter = { | ||
data: readOutDataAndRecords[i].item, | ||
data, | ||
parameters: fragmentReference.variables, | ||
}; | ||
|
||
|
@@ -165,10 +170,17 @@ export function useConnectionSpecPagination< | |
fragmentReference.readerWithRefetchQueries, | ||
); | ||
|
||
const records = readOutDataAndRecords[i]; | ||
if (records == null) { | ||
throw new Error( | ||
'subscribeCompletedFragmentReferences records is unexpectedly null', | ||
); | ||
} | ||
|
||
return { | ||
fragmentReference, | ||
readerAst: readerWithRefetchQueries.readerArtifact.readerAst, | ||
records: readOutDataAndRecords[i], | ||
records, | ||
callback(_data) { | ||
rerender({}); | ||
}, | ||
|
@@ -224,10 +236,9 @@ export function useConnectionSpecPagination< | |
|
||
const loadedReferences = state === UNASSIGNED_STATE ? [] : state; | ||
|
||
const mostRecentItem: LoadedFragmentReference< | ||
TReadFromStore, | ||
Connection<TItem> | ||
> | null = loadedReferences[loadedReferences.length - 1]; | ||
const mostRecentItem: | ||
| LoadedFragmentReference<TReadFromStore, Connection<TItem>> | ||
| undefined = loadedReferences[loadedReferences.length - 1]; | ||
const mostRecentFragmentReference = | ||
mostRecentItem?.[0].getItemIfNotDisposed(); | ||
|
||
|
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.
oops, this can never be null... the field is not optional. This is probably a holdover from a previous time. perhaps something like https://typescript-eslint.io/rules/no-unnecessary-condition/ can prevent this in the future
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.
Removed!