From ff1e10e58eee329a7f0ae4b978239b04559d388e Mon Sep 17 00:00:00 2001 From: Martin Jesper Low Madsen Date: Mon, 4 May 2020 20:42:47 +0200 Subject: [PATCH 1/2] enhancement(transformer): Mock Date similar to that of Set and Map --- src/transformer/descriptor/tsLibs/typecriptLibs.ts | 2 ++ .../descriptor/tsLibs/typescriptLibsTypes.ts | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/transformer/descriptor/tsLibs/typecriptLibs.ts b/src/transformer/descriptor/tsLibs/typecriptLibs.ts index 83fa84a72..9c93f0f8e 100644 --- a/src/transformer/descriptor/tsLibs/typecriptLibs.ts +++ b/src/transformer/descriptor/tsLibs/typecriptLibs.ts @@ -46,6 +46,8 @@ export function GetTypescriptTypeDescriptor(node: ts.TypeReferenceNode, scope: S [], [dataResolved], ); + case(TypescriptLibsTypes.Date): + return ts.createNew(ts.createIdentifier('Date'), undefined, undefined); case(TypescriptLibsTypes.Map): return ts.createNew(ts.createIdentifier('Map'), undefined, undefined); case(TypescriptLibsTypes.Set): diff --git a/src/transformer/descriptor/tsLibs/typescriptLibsTypes.ts b/src/transformer/descriptor/tsLibs/typescriptLibsTypes.ts index 4cedec570..3e7304683 100644 --- a/src/transformer/descriptor/tsLibs/typescriptLibsTypes.ts +++ b/src/transformer/descriptor/tsLibs/typescriptLibsTypes.ts @@ -1,14 +1,15 @@ export enum TypescriptLibsTypes { Array = 'Array', - ReadonlyArray = 'ReadonlyArray', - Number = 'Number', - String = 'String', Boolean = 'Boolean', - Object = 'Object', + Date = 'Date', Function = 'Function', - Promise = 'Promise', Map = 'Map', - Set = 'Set' + Number = 'Number', + Object = 'Object', + Promise = 'Promise', + ReadonlyArray = 'ReadonlyArray', + Set = 'Set', + String = 'String', } export const TypescriptLibsTypesFolder: string = 'node_modules/typescript/lib'; From d7362ff9085d6b603d65a7c75ce3655f45d65bc4 Mon Sep 17 00:00:00 2001 From: Martin Jesper Low Madsen Date: Fri, 8 May 2020 15:38:59 +0200 Subject: [PATCH 2/2] chore(transformer): Update TypeScript lib type test for Date --- test/transformer/descriptor/tsLibs/tsLibs.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/transformer/descriptor/tsLibs/tsLibs.test.ts b/test/transformer/descriptor/tsLibs/tsLibs.test.ts index 5999aba7f..5ba03897f 100644 --- a/test/transformer/descriptor/tsLibs/tsLibs.test.ts +++ b/test/transformer/descriptor/tsLibs/tsLibs.test.ts @@ -66,13 +66,13 @@ describe('typescript lib', () => { expect(properties.a).toEqual([]); }); - it('should set undefined for a Date', () => { + it('should create a new Date for a Date', () => { interface Interface { a: Date; } const properties: Interface = createMock(); - expect(properties.a).toBeUndefined(); + expect(properties.a).toBeInstanceOf(Date); }); it('should set a promise resolved for a promise', async () => {