#8267·mikro-orm

How to carry `forceUndefined: true` over to inferred types?

Author: robby-cornelissenCreated Sep 10, 2026Updated Sep 10, 2026

I can force MikroORM to return undefined instead of null for NULL values, which is great:

typescript
defineConfig({
  // ...
  forceUndefined: true,
});

But, when I define an entity, and let MikroORM infer its TypeScript type like below, the name property's type will be inferred as string | null | undefined.

typescript
export const SomeEntity = defineEntity({
  name: 'Some',
  properties: {
    name: p.string().nullable(),
  }
});

type Some = InferEntity<typeof SomeEntity>;

How do I change the above entity definition so that null is dropped from the union, and the name property's type is correctly inferred as string | undefined?