Skip to content

Commit 12d2008

Browse files
authored
fix: missing mapped type transformer (#219)
* Add missing mapped type transformer * Add newline * Add missing test case
1 parent cfa7bdf commit 12d2008

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

packages/ripple/src/compiler/phases/3-transform/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ const visitors = {
230230
context.next();
231231
},
232232

233+
TSMappedType(_, context) {
234+
if (!context.state.to_ts) {
235+
return b.empty;
236+
}
237+
context.next();
238+
},
239+
233240
NewExpression(node, context) {
234241
const callee = node.callee;
235242
const parent = context.path.at(-1);

packages/ripple/tests/compiler.test.ripple

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,34 @@ describe('compiler success tests', () => {
178178
124, 123, 124, 123, 124, 123, 124, 123
179179
]);
180180
});
181-
});
181+
182+
it('renders without crashing using mapped types', () => {
183+
component App() {
184+
type RecordKey = 'test';
185+
type RecordValue = { a: string, b: number };
186+
187+
const config: Record<RecordKey, RecordValue> = {
188+
test: {
189+
a: 'test',
190+
b: 1
191+
},
192+
};
193+
194+
const config2: { [key in RecordKey]: RecordValue } = {
195+
test: {
196+
a: 'test2',
197+
b: 2
198+
}
199+
}
200+
201+
const config3: { [key: RecordKey]: RecordValue } = {
202+
test: {
203+
a: 'test3',
204+
b: 3
205+
}
206+
}
207+
}
208+
209+
render(App);
210+
});
211+
});

0 commit comments

Comments
 (0)