Skip to content

Commit

Permalink
actually get typescript 5.5 to work
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Jun 24, 2024
1 parent b7debf3 commit 8b49db7
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 70 deletions.
4 changes: 2 additions & 2 deletions packages/payload/src/auth/executeAuthStrategies.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { GeneratedTypes } from '../index.js'
import type { TypedUser } from '../index.js'
import type { AuthStrategyFunctionArgs } from './index.js'

export const executeAuthStrategies = async (
args: AuthStrategyFunctionArgs,
): Promise<GeneratedTypes['user'] | null> => {
): Promise<TypedUser | null> => {
return args.payload.authStrategies.reduce(async (accumulatorPromise, strategy) => {
const authUser = await accumulatorPromise
if (!authUser) {
Expand Down
4 changes: 2 additions & 2 deletions packages/payload/src/auth/operations/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GeneratedTypes } from '../../index.js'
import type { TypedUser } from '../../index.js'
import type { PayloadRequestWithData } from '../../types/index.js'
import type { Permissions } from '../types.js'

Expand All @@ -15,7 +15,7 @@ export type AuthArgs = {

export type AuthResult = {
permissions: Permissions
user: GeneratedTypes['user'] | null
user: TypedUser | null
}

export const auth = async (args: Required<AuthArgs>): Promise<AuthResult> => {
Expand Down
5 changes: 2 additions & 3 deletions packages/payload/src/collections/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
} from '../../config/types.js'
import type { DBIdentifierName } from '../../database/types.js'
import type { Field } from '../../fields/config/types.js'
import type { CollectionSlug, GeneratedTypes } from '../../index.js'
import type { CollectionSlug, TypedCollection } from '../../index.js'
import type { PayloadRequestWithData, RequestContext } from '../../types/index.js'
import type { SanitizedUploadConfig, UploadConfig } from '../../uploads/types.js'
import type {
Expand All @@ -31,8 +31,7 @@ import type {
} from '../../versions/types.js'
import type { AfterOperationArg, AfterOperationMap } from '../operations/utils.js'

export type DataFromCollectionSlug<TSlug extends CollectionSlug> =
GeneratedTypes['collections'][TSlug]
export type DataFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollection[TSlug]

export type RequiredDataFromCollection<TData extends Record<string, any>> = MarkOptional<
TData,
Expand Down
4 changes: 2 additions & 2 deletions packages/payload/src/collections/operations/local/count.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type {
Document,
PayloadRequestWithData,
Expand All @@ -18,7 +18,7 @@ export type Options<TSlug extends CollectionSlug> = {
context?: RequestContext
depth?: number
disableErrors?: boolean
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
user?: Document
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/collections/operations/local/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'
import type { File } from '../../../uploads/types.js'
import type { DataFromCollectionSlug, RequiredDataFromCollectionSlug } from '../../config/types.js'
Expand All @@ -18,10 +18,10 @@ export type Options<TSlug extends CollectionSlug> = {
depth?: number
disableVerificationEmail?: boolean
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
file?: File
filePath?: string
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
overwriteExistingFiles?: boolean
req?: PayloadRequestWithData
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/collections/operations/local/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type {
Document,
PayloadRequestWithData,
Expand All @@ -19,8 +19,8 @@ export type BaseOptions<TSlug extends CollectionSlug> = {
*/
context?: RequestContext
depth?: number
fallbackLocale?: GeneratedTypes['locale']
locale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes } from '../../..//index.js'
import type { CollectionSlug, TypedLocale } from '../../..//index.js'
import type { Payload } from '../../../index.js'
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'
import type { DataFromCollectionSlug } from '../../config/types.js'
Expand All @@ -15,9 +15,9 @@ export type Options<TSlug extends CollectionSlug> = {
context?: RequestContext
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: number | string
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/collections/operations/local/find.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaginatedDocs } from '../../../database/types.js'
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type {
Document,
PayloadRequestWithData,
Expand All @@ -22,9 +22,9 @@ export type Options<TSlug extends CollectionSlug> = {
depth?: number
disableErrors?: boolean
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
limit?: number
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
page?: number
pagination?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/collections/operations/local/findByID.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'
import type { DataFromCollectionSlug } from '../../config/types.js'

Expand All @@ -16,9 +16,9 @@ export type Options<TSlug extends CollectionSlug> = {
depth?: number
disableErrors?: boolean
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: number | string
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'
import type { TypeWithVersion } from '../../../versions/types.js'
import type { DataFromCollectionSlug } from '../../config/types.js'
Expand All @@ -16,9 +16,9 @@ export type Options<TSlug extends CollectionSlug> = {
depth?: number
disableErrors?: boolean
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: string
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaginatedDocs } from '../../../database/types.js'
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type {
Document,
PayloadRequestWithData,
Expand All @@ -21,9 +21,9 @@ export type Options<TSlug extends CollectionSlug> = {
context?: RequestContext
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
limit?: number
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
page?: number
req?: PayloadRequestWithData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'
import type { DataFromCollectionSlug } from '../../config/types.js'

Expand All @@ -14,9 +14,9 @@ export type Options<TSlug extends CollectionSlug> = {
context?: RequestContext
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: string
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/collections/operations/local/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DeepPartial } from 'ts-essentials'

import type { CollectionSlug, GeneratedTypes, Payload } from '../../../index.js'
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'
import type {
Document,
PayloadRequestWithData,
Expand Down Expand Up @@ -30,10 +30,10 @@ export type BaseOptions<TSlug extends CollectionSlug> = {
data: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
file?: File
filePath?: string
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
overwriteExistingFiles?: boolean
req?: PayloadRequestWithData
Expand Down
5 changes: 2 additions & 3 deletions packages/payload/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
} from '@payloadcms/translations'
import type { Options as ExpressFileUploadOptions } from 'express-fileupload'
import type GraphQL from 'graphql'
import type { Metadata as NextMetadata } from 'next'
import type { DestinationStream, LoggerOptions } from 'pino'
import type React from 'react'
import type { JSX } from 'react'
Expand All @@ -26,7 +25,7 @@ import type {
import type { DatabaseAdapterResult } from '../database/types.js'
import type { EmailAdapter, SendEmailOptions } from '../email/types.js'
import type { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js'
import type { GeneratedTypes, Payload } from '../index.js'
import type { Payload, TypedUser } from '../index.js'
import type { PayloadRequest, PayloadRequestWithData, Where } from '../types/index.js'
import type { PayloadLogger } from '../utilities/logger.js'

Expand Down Expand Up @@ -333,7 +332,7 @@ export type ServerProps = {
payload: Payload
permissions?: Permissions
searchParams?: { [key: string]: string | string[] | undefined }
user?: GeneratedTypes['user']
user?: TypedUser
}

export const serverProps: (keyof ServerProps)[] = [
Expand Down
4 changes: 2 additions & 2 deletions packages/payload/src/globals/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import type {
} from '../../config/types.js'
import type { DBIdentifierName } from '../../database/types.js'
import type { Field } from '../../fields/config/types.js'
import type { GeneratedTypes, GlobalSlug } from '../../index.js'
import type { GlobalSlug, TypedGlobal } from '../../index.js'
import type { PayloadRequestWithData, RequestContext, Where } from '../../types/index.js'
import type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'

export type DataFromGlobalSlug<TSlug extends GlobalSlug> = GeneratedTypes['globals'][TSlug]
export type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]

export type BeforeValidateHook = (args: {
context: RequestContext
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/globals/operations/local/findOne.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GeneratedTypes, GlobalSlug, Payload, RequestContext } from '../../../index.js'
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData } from '../../../types/index.js'
import type { DataFromGlobalSlug } from '../../config/types.js'

Expand All @@ -10,8 +10,8 @@ export type Options<TSlug extends GlobalSlug> = {
context?: RequestContext
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
locale?: 'all' | GeneratedTypes['locale']
fallbackLocale?: TypedLocale
locale?: 'all' | TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GeneratedTypes, GlobalSlug, Payload, RequestContext } from '../../../index.js'
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData } from '../../../types/index.js'
import type { TypeWithVersion } from '../../../versions/types.js'
import type { DataFromGlobalSlug } from '../../config/types.js'
Expand All @@ -11,9 +11,9 @@ export type Options<TSlug extends GlobalSlug> = {
context?: RequestContext
depth?: number
disableErrors?: boolean
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: string
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/globals/operations/local/findVersions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaginatedDocs } from '../../../database/types.js'
import type { GeneratedTypes, GlobalSlug, Payload, RequestContext } from '../../../index.js'
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData, Where } from '../../../types/index.js'
import type { TypeWithVersion } from '../../../versions/types.js'
import type { DataFromGlobalSlug } from '../../config/types.js'
Expand All @@ -11,9 +11,9 @@ import { findVersionsOperation } from '../findVersions.js'
export type Options<TSlug extends GlobalSlug> = {
context?: RequestContext
depth?: number
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
limit?: number
locale?: 'all' | GeneratedTypes['locale']
locale?: 'all' | TypedLocale
overrideAccess?: boolean
page?: number
req?: PayloadRequestWithData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GeneratedTypes, GlobalSlug, Payload, RequestContext } from '../../../index.js'
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData } from '../../../types/index.js'
import type { DataFromGlobalSlug } from '../../config/types.js'

Expand All @@ -9,9 +9,9 @@ import { restoreVersionOperation } from '../restoreVersion.js'
export type Options<TSlug extends GlobalSlug> = {
context?: RequestContext
depth?: number
fallbackLocale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
id: string
locale?: GeneratedTypes['locale']
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/src/globals/operations/local/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DeepPartial } from 'ts-essentials'

import type { GeneratedTypes, GlobalSlug, Payload, RequestContext } from '../../../index.js'
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'
import type { Document, PayloadRequestWithData } from '../../../types/index.js'
import type { DataFromGlobalSlug } from '../../config/types.js'

Expand All @@ -13,8 +13,8 @@ export type Options<TSlug extends GlobalSlug> = {
data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>
depth?: number
draft?: boolean
fallbackLocale?: GeneratedTypes['locale']
locale?: GeneratedTypes['locale']
fallbackLocale?: TypedLocale
locale?: TypedLocale
overrideAccess?: boolean
req?: PayloadRequestWithData
showHiddenFields?: boolean
Expand Down
Loading

0 comments on commit 8b49db7

Please sign in to comment.