ci: template errors not being caught due. fix: error due to updated generated-types User type (#12973)
This PR consists of two separate changes. One change cannot pass CI without the other, so both are included in this single PR. ## CI - ensure types are generated Our website template is currently failing to build due to a type error. This error was introduced by a change in our generated types. Our CI did not catch this issue because it wasn't generating types / import map before attempting to build the templates. This PR updates the CI to generate types first. It also updates some CI step names for improved clarity. ## Fix: type error  This fixes the type error by ensuring we consistently use the _same_ generated `TypedUser` object within payload, instead of `BaseUser`. Previously, we sometimes used the generated-types user and sometimes the base user, which was causing type conflicts depending on what the generated user type was. It also deprecates the `User` type (which was essentially just `BaseUser`), as consumers should use `TypedUser` instead. `TypedUser` will automatically fall back to `BaseUser` if no generated types exists, but will accept passing it a generated-types User. Without this change, additional properties added to the user via generated-types may cause the user object to not be accepted by functions that only accept a `User` instead of a `TypedUser`, which is what failed here. ## Templates: re-generate templates to update generated types --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210668927737258
This commit is contained in:
@@ -4,7 +4,7 @@ import type {
|
||||
FormField,
|
||||
FormState,
|
||||
Row,
|
||||
User,
|
||||
TypedUser,
|
||||
ValidationFieldError,
|
||||
} from 'payload'
|
||||
import type React from 'react'
|
||||
@@ -123,7 +123,7 @@ export type MODIFY_CONDITION = {
|
||||
path: string
|
||||
result: boolean
|
||||
type: 'MODIFY_CONDITION'
|
||||
user: User
|
||||
user: TypedUser
|
||||
}
|
||||
|
||||
export type UPDATE = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
PayloadRequest,
|
||||
SelectMode,
|
||||
SelectType,
|
||||
User,
|
||||
TypedUser,
|
||||
} from 'payload'
|
||||
|
||||
import { iterateFields } from './iterateFields.js'
|
||||
@@ -18,7 +18,7 @@ type Args = {
|
||||
select?: SelectType
|
||||
selectMode?: SelectMode
|
||||
siblingData: Data
|
||||
user: User
|
||||
user: TypedUser
|
||||
}
|
||||
|
||||
export const calculateDefaultValues = async ({
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import type { Data, Field, PayloadRequest, SelectMode, SelectType, TabAsField, User } from 'payload'
|
||||
import type {
|
||||
Data,
|
||||
Field,
|
||||
PayloadRequest,
|
||||
SelectMode,
|
||||
SelectType,
|
||||
TabAsField,
|
||||
TypedUser,
|
||||
} from 'payload'
|
||||
|
||||
import { defaultValuePromise } from './promise.js'
|
||||
|
||||
@@ -11,7 +19,7 @@ type Args<T> = {
|
||||
select?: SelectType
|
||||
selectMode?: SelectMode
|
||||
siblingData: Data
|
||||
user: User
|
||||
user: TypedUser
|
||||
}
|
||||
|
||||
export const iterateFields = async <T>({
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
SelectMode,
|
||||
SelectType,
|
||||
TabAsField,
|
||||
User,
|
||||
TypedUser,
|
||||
} from 'payload'
|
||||
|
||||
import { getBlockSelect, getDefaultValue, stripUnselectedFields } from 'payload'
|
||||
@@ -23,7 +23,7 @@ type Args<T> = {
|
||||
select?: SelectType
|
||||
selectMode?: SelectMode
|
||||
siblingData: Data
|
||||
user: User
|
||||
user: TypedUser
|
||||
}
|
||||
|
||||
// TODO: Make this works for rich text subfields
|
||||
|
||||
Reference in New Issue
Block a user