Deprecate FieldMetadataInterface (#13264)
# Introduction
From the moment replaced the FieldMetadataInterface definition to:
```ts
import { FieldMetadataType } from 'twenty-shared/types';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
export type FieldMetadataInterface<
T extends FieldMetadataType = FieldMetadataType,
> = FieldMetadataEntity<T>;
```
After this PR merge will create a new one removing the type and
replacing it to `FieldMetadataEntity`.
Did not renamed it here to avoid conflicts on naming + type issues fixs
within the same PR
## Field metadata entity RELATION or MORPH
Relations fields cannot be null for those field metadata entity instance
anymore, but are never for the others see
`packages/twenty-server/src/engine/metadata-modules/field-metadata/types/field-metadata-entity-test.type.ts`
( introduced TypeScript tests )
## Concerns
- TS_VECTOR is the most at risk with the `generatedType` and
`asExpression` removal from interface
## What's next
- `FielMetadataInterface` removal and rename ( see introduction )
- Depcrecating `ObjectMetadataInterface`
- Refactor `FieldMetadataEntity` optional fiels to be nullable only
- TO DIG `never` occurences on settings, defaultValue etc
- Some interfaces will be replaced by the `FlatFieldMetadata` when
deprecating the current sync and comparators tools
This commit is contained in:
@ -6,6 +6,7 @@ export const eachTestingContextFilter = <T>(
|
||||
const onlyTestsCases = testCases.filter((testCase) => testCase.only === true);
|
||||
|
||||
if (process.env.CI && onlyTestsCases.length > 0) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
'Should never push tests cases with an only to true, only to use in dev env\n returning the whole test suite anyway',
|
||||
);
|
||||
|
||||
@ -10,3 +10,8 @@
|
||||
export { eachTestingContextFilter } from './EachTestingContextFilter';
|
||||
export type { EachTestingContext } from './types/EachTestingContext.type';
|
||||
export type { SuccessfulAndFailingTestCases } from './types/SuccessfulAndFailingTestCases';
|
||||
export type {
|
||||
Expect,
|
||||
Equal,
|
||||
HasAllProperties,
|
||||
} from './types/TestingGenerics.type';
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Type testing utilities for TypeScript
|
||||
* @module TypeTesting
|
||||
*/
|
||||
|
||||
/**
|
||||
* A type utility for testing TypeScript type assertions
|
||||
*
|
||||
* @template T - The actual type to test
|
||||
*/
|
||||
export type Expect<T extends true> = T;
|
||||
|
||||
/**
|
||||
* Tests if two types are exactly equal
|
||||
*
|
||||
* @template A - First type to compare
|
||||
* @template B - Second type to compare
|
||||
*/
|
||||
export type Equal<A, B> =
|
||||
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
|
||||
? true
|
||||
: false;
|
||||
|
||||
/**
|
||||
* Tests if a type has all required properties of another type
|
||||
* Works with both class types and regular object types
|
||||
*
|
||||
* @template T - Type that should contain the properties
|
||||
* @template U - Type whose properties should be contained in T
|
||||
*/
|
||||
export type HasAllProperties<T, U> = [T] extends [new (...args: any[]) => any]
|
||||
? HasAllProperties<InstanceType<T>, U>
|
||||
: [U] extends [new (...args: any[]) => any]
|
||||
? HasAllProperties<T, InstanceType<U>>
|
||||
: {
|
||||
[K in keyof U]: K extends keyof T ? Equal<T[K], U[K]> : false;
|
||||
}[keyof U] extends true
|
||||
? true
|
||||
: false;
|
||||
|
||||
class TestClass {
|
||||
id!: string;
|
||||
name!: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
type BasicTests = [
|
||||
Expect<Equal<string, string>>,
|
||||
Expect<Equal<number, number>>,
|
||||
Expect<Equal<{ a: string }, { a: string }>>,
|
||||
|
||||
Expect<HasAllProperties<{ a: string; b: number }, { a: string }>>,
|
||||
Expect<HasAllProperties<{ a: string; b: number }, { a: string; b: number }>>,
|
||||
|
||||
Expect<HasAllProperties<{ a: never; b: never }, { a: never }>>,
|
||||
|
||||
Expect<HasAllProperties<TestClass, { id: string }>>,
|
||||
Expect<HasAllProperties<{ id: string; name: string }, { id: string }>>,
|
||||
];
|
||||
Reference in New Issue
Block a user