[QRQC_2] No implicitAny in twenty-server (#12075)
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
This commit is contained in:
@ -3,8 +3,7 @@ import { Transform } from 'class-transformer';
|
||||
export const CastToPositiveNumber = () =>
|
||||
Transform(({ value }: { value: string }) => toNumber(value));
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const toNumber = (value: any) => {
|
||||
const toNumber = (value: unknown): number | undefined => {
|
||||
if (typeof value === 'number') {
|
||||
return value >= 0 ? value : undefined;
|
||||
}
|
||||
|
||||
@ -382,6 +382,7 @@ describe('TwentyConfigService', () => {
|
||||
SENSITIVE_VAR: 'sensitive_data_123',
|
||||
};
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return values[keyStr] || undefined;
|
||||
});
|
||||
|
||||
@ -390,6 +391,7 @@ describe('TwentyConfigService', () => {
|
||||
.mockImplementation((key: keyof ConfigVariables) => {
|
||||
const keyStr = String(key);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
if (mockConfigVarMetadata[keyStr]?.isEnvOnly) {
|
||||
return environmentConfigDriver.get(key);
|
||||
}
|
||||
@ -398,6 +400,7 @@ describe('TwentyConfigService', () => {
|
||||
SENSITIVE_VAR: 'sensitive_data_123',
|
||||
};
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return values[keyStr] || undefined;
|
||||
});
|
||||
};
|
||||
|
||||
@ -64,12 +64,14 @@ describe('applyBasicValidators', () => {
|
||||
const mockTransformParams = { value: 'true' };
|
||||
|
||||
(configTransformers.boolean as jest.Mock).mockReturnValueOnce(true);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const result1 = transformFn(mockTransformParams);
|
||||
|
||||
expect(configTransformers.boolean).toHaveBeenCalledWith('true');
|
||||
expect(result1).toBe(true);
|
||||
|
||||
(configTransformers.boolean as jest.Mock).mockReturnValueOnce(undefined);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const result2 = transformFn(mockTransformParams);
|
||||
|
||||
expect(result2).toBe('true');
|
||||
@ -99,12 +101,14 @@ describe('applyBasicValidators', () => {
|
||||
const mockTransformParams = { value: '42' };
|
||||
|
||||
(configTransformers.number as jest.Mock).mockReturnValueOnce(42);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const result1 = transformFn(mockTransformParams);
|
||||
|
||||
expect(configTransformers.number).toHaveBeenCalledWith('42');
|
||||
expect(result1).toBe(42);
|
||||
|
||||
(configTransformers.number as jest.Mock).mockReturnValueOnce(undefined);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const result2 = transformFn(mockTransformParams);
|
||||
|
||||
expect(result2).toBe('42');
|
||||
|
||||
Reference in New Issue
Block a user