mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 17:30:25 -04:00
ca4b3bc624
* Refactor `StorageMenu` modals to replace deprecated patterns * add test for `DeleteBucketModal` and update test setup Note: Because this component uses `useParams`, it's necessary to have the dynamic route segment passed to `next-router-mock`'s `createDynamicRouteParser`. In order not to have to manually list all of these as the application grows, I added a glob utility that uses the `pages/` directory to automatically generate an array of dynamic route paths in this case. * add test for `EmptyBucketModal` * add test for `EditBucketModal` and add `isNonNullable` utility function * add test for `CreateBucketModal` * implement requested changes * implement visual fixes
23 lines
558 B
TypeScript
23 lines
558 B
TypeScript
export type Maybe<T> = T | null | undefined
|
|
|
|
/**
|
|
* Used to test whether a `Maybe` typed value is `null` or `undefined`.
|
|
*
|
|
* When called, the given value's type is narrowed to `NonNullable<T>`.
|
|
*
|
|
* ### Example Usage:
|
|
*
|
|
* ```ts
|
|
* const fn = (str: Maybe<string>) => {
|
|
* if (!isNonNullable(str)) {
|
|
* // typeof str = null | undefined
|
|
* // ...
|
|
* }
|
|
* // typeof str = string
|
|
* // ...
|
|
* }
|
|
* ```
|
|
*/
|
|
export const isNonNullable = <T extends Maybe<unknown>>(val?: T): val is NonNullable<T> =>
|
|
typeof val !== `undefined` && val !== null
|