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:
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user