-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(core): amplify configure with storage path type issue #14088
fix(core): amplify configure with storage path type issue #14088
Conversation
@@ -53,7 +53,7 @@ export interface AmplifyOutputsStorageBucketProperties { | |||
/** Region for the bucket */ | |||
aws_region: string; | |||
/** Paths to object with access permissions */ | |||
paths?: Record<string, Record<string, string[] | undefined>>; | |||
paths?: Partial<Record<string, Record<string, string[] | undefined>>>; |
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.
note:
We have added Partial for AmplifyOutputs here but not for the Amplify singleton in itself. Adding Partial
to the singleton would mean we would need to update additional APIs that consume path since they expect a stricter type from the singleton.
Hence the additional parsing logic above in parseAmplifyOutputs.ts
is required
(same goes auth userGroups as well)
@@ -383,10 +383,22 @@ function createBucketInfoMap( | |||
); | |||
} | |||
|
|||
const sanitizedPaths = paths |
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.
The sanitization step is required to convert Partial<Record<string, ...>>
type to Record<string, ...>
by removing undefined values. i.e remove Partial
.
Description of changes
Amplify configure with storage, with multiple buckets with unique paths throws a type error
Type 'undefined' is not assignable to type 'Record<string, string[] | undefined>
. This PR loosens this type to avoid this error.Description of how you validated changes
amplify.configure
does not throw any type erroramplify.getConfig
returns the correct configChecklist
yarn test
passesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.