Skip to content

Commit 7480aad

Browse files
authored
feat(date): add support for Date type (#310)
* enhancement(transformer): Mock Date similar to that of Set and Map * chore(transformer): Update TypeScript lib type test for Date
1 parent 9965667 commit 7480aad

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/transformer/descriptor/tsLibs/typecriptLibs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function GetTypescriptTypeDescriptor(node: ts.TypeReferenceNode, scope: S
4646
[],
4747
[dataResolved],
4848
);
49+
case(TypescriptLibsTypes.Date):
50+
return ts.createNew(ts.createIdentifier('Date'), undefined, undefined);
4951
case(TypescriptLibsTypes.Map):
5052
return ts.createNew(ts.createIdentifier('Map'), undefined, undefined);
5153
case(TypescriptLibsTypes.Set):
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
export enum TypescriptLibsTypes {
22
Array = 'Array',
3-
ReadonlyArray = 'ReadonlyArray',
4-
Number = 'Number',
5-
String = 'String',
63
Boolean = 'Boolean',
7-
Object = 'Object',
4+
Date = 'Date',
85
Function = 'Function',
9-
Promise = 'Promise',
106
Map = 'Map',
11-
Set = 'Set'
7+
Number = 'Number',
8+
Object = 'Object',
9+
Promise = 'Promise',
10+
ReadonlyArray = 'ReadonlyArray',
11+
Set = 'Set',
12+
String = 'String',
1213
}
1314

1415
export const TypescriptLibsTypesFolder: string = 'node_modules/typescript/lib';

test/transformer/descriptor/tsLibs/tsLibs.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ describe('typescript lib', () => {
6666
expect(properties.a).toEqual([]);
6767
});
6868

69-
it('should set undefined for a Date', () => {
69+
it('should create a new Date for a Date', () => {
7070
interface Interface {
7171
a: Date;
7272
}
7373

7474
const properties: Interface = createMock<Interface>();
75-
expect(properties.a).toBeUndefined();
75+
expect(properties.a).toBeInstanceOf(Date);
7676
});
7777

7878
it('should set a promise resolved for a promise', async () => {

0 commit comments

Comments
 (0)