Explorar el Código

make userHomepagePath typesafe

Yuki Takei hace 2 años
padre
commit
9f70b84636
Se han modificado 1 ficheros con 4 adiciones y 3 borrados
  1. 4 3
      packages/core/src/utils/page-path-utils/index.ts

+ 4 - 3
packages/core/src/utils/page-path-utils/index.ts

@@ -1,5 +1,7 @@
 import escapeStringRegexp from 'escape-string-regexp';
 import escapeStringRegexp from 'escape-string-regexp';
 
 
+import { IUser } from '~/interfaces';
+
 import { isValidObjectId } from '../objectid-utils';
 import { isValidObjectId } from '../objectid-utils';
 import { addTrailingSlash } from '../path-utils';
 import { addTrailingSlash } from '../path-utils';
 
 
@@ -124,9 +126,8 @@ export const isCreatablePage = (path: string): boolean => {
  * return user's homepage path
  * return user's homepage path
  * @param user
  * @param user
  */
  */
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const userHomepagePath = (user: any): string => {
-  if (!user || !user.username) {
+export const userHomepagePath = (user: IUser | null | undefined): string => {
+  if (user?.username == null) {
     return '';
     return '';
   }
   }
   return `/user/${user.username}`;
   return `/user/${user.username}`;