feat!: type auto-generation (#6657)

Types are now auto-generated by default.

You can opt-out of this behavior by setting:
```ts
buildConfig({
  // Rest of config
  typescript: {
    autoGenerate: false
  },
})
```
This commit is contained in:
Elliot DeNolf
2024-06-10 13:42:44 -04:00
committed by GitHub
parent 45e86832c2
commit 7309d474ee
81 changed files with 743 additions and 39 deletions

View File

@@ -2,6 +2,7 @@ import type { GeneratedTypes, Payload } from 'payload'
import type { InitOptions, SanitizedConfig } from 'payload/config'
import { BasePayload } from 'payload'
import { generateTypes } from 'payload/bin'
import WebSocket from 'ws'
let cached: {
@@ -36,6 +37,11 @@ export const reload = async (config: SanitizedConfig, payload: Payload): Promise
// TODO: support HMR for other props in the future (see payload/src/index init()) hat may change on Payload singleton
// Generate types
if (config.typescript.autoGenerate !== false) {
void generateTypes(config, { log: false })
}
await payload.db.init()
if (payload.db.connect) {
await payload.db.connect({ hotReload: true })