Skip to content

Commit cca3608

Browse files
committed
fix: Simplify GenericTypeAnnotation structure in mapperFor function and tests
1 parent 55e2001 commit cca3608

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

resources/buildConfigDefinitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function mapperFor(elt, t) {
158158
} else if (t.isObjectTypeAnnotation(elt)) {
159159
return wrap(t.identifier('objectParser'));
160160
} else if (t.isGenericTypeAnnotation(elt)) {
161-
const type = elt.typeAnnotation.id.name;
161+
const type = elt.id.name;
162162
if (type == 'Adapter') {
163163
return wrap(t.identifier('moduleOrObjectParser'));
164164
}

spec/buildConfigDefinitions.spec.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ describe('buildConfigDefinitions', () => {
6767
it('should return moduleOrObjectParser for Adapter GenericTypeAnnotation', () => {
6868
const mockElement = {
6969
type: 'GenericTypeAnnotation',
70-
typeAnnotation: {
71-
id: {
72-
name: 'Adapter',
73-
},
70+
id: {
71+
name: 'Adapter',
7472
},
7573
};
7674

@@ -84,10 +82,8 @@ describe('buildConfigDefinitions', () => {
8482
it('should return numberOrBooleanParser for NumberOrBoolean GenericTypeAnnotation', () => {
8583
const mockElement = {
8684
type: 'GenericTypeAnnotation',
87-
typeAnnotation: {
88-
id: {
89-
name: 'NumberOrBoolean',
90-
},
85+
id: {
86+
name: 'NumberOrBoolean',
9187
},
9288
};
9389

@@ -102,10 +98,8 @@ describe('buildConfigDefinitions', () => {
10298
const mockElement = {
10399
type: 'GenericTypeAnnotation',
104100
name: 'testString',
105-
typeAnnotation: {
106-
id: {
107-
name: 'NumberOrString',
108-
},
101+
id: {
102+
name: 'NumberOrString',
109103
},
110104
};
111105

@@ -119,10 +113,8 @@ describe('buildConfigDefinitions', () => {
119113
it('should return arrayParser for StringOrStringArray GenericTypeAnnotation', () => {
120114
const mockElement = {
121115
type: 'GenericTypeAnnotation',
122-
typeAnnotation: {
123-
id: {
124-
name: 'StringOrStringArray',
125-
},
116+
id: {
117+
name: 'StringOrStringArray',
126118
},
127119
};
128120

@@ -136,10 +128,8 @@ describe('buildConfigDefinitions', () => {
136128
it('should return objectParser for unknown GenericTypeAnnotation', () => {
137129
const mockElement = {
138130
type: 'GenericTypeAnnotation',
139-
typeAnnotation: {
140-
id: {
141-
name: 'UnknownType',
142-
},
131+
id: {
132+
name: 'UnknownType',
143133
},
144134
};
145135

0 commit comments

Comments
 (0)