-
Notifications
You must be signed in to change notification settings - Fork 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
Typescript error with 16.9.0 (re ThunkObjMap) #4129
Comments
Your type would be fixed by doing the following for (const value of Object.keys(values)) {
if (typeof config.values === 'object') {
config.values[value] = { value }
}
} For some reason TypeScript gets confused and thinks you might be assigning the mapping to either a function or an object due to the addition of the possibility of assigning values through a thunk. EDIT: Alternatively changing the type also works, this is because the upcast happens due to the explicit type of config. const config = { name, values: {} as { [key: string]: GraphQLEnumValueConfig } } |
Thanks a lot for the fast and helpful reply! This fixes it. Edit: forcing the type of |
Going to close this issue out as it doesn't look like there's more to discuss here, I this in part comes back to GraphQL-JS exporting too many utility types 😅 the type gets expanded by casting to |
Hi,
after upgrading to 16.9.0 our utility function for building enums shows a typescript error (using noImplicitAny). The function looks as follows:
The error is for "config.values[value]":
Is this intended? And how is this supposed to be migrated?
The text was updated successfully, but these errors were encountered: