Skip to content

Commit cc7e890

Browse files
authored
fix: respect {} in safe typestring splitting (#46)
* fix: respect {} in safe typestring splitting * test * lint
1 parent 91d116e commit cc7e890

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/__tests__/__snapshots__/markdown-helpers.spec.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`markdown-helpers rawTypeToTypeInformation() should allow commas in object types 1`] = `
4+
Object {
5+
"collection": false,
6+
"parameters": Array [],
7+
"returns": Object {
8+
"collection": false,
9+
"type": "{a: string, b: string}",
10+
},
11+
"type": "Function",
12+
}
13+
`;
14+
315
exports[`markdown-helpers rawTypeToTypeInformation() should map a Promise types correctly 1`] = `
416
Object {
517
"collection": false,

src/__tests__/markdown-helpers.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ def fn():
288288
),
289289
).toMatchSnapshot();
290290
});
291+
292+
it('should allow commas in object types', () => {
293+
expect(
294+
rawTypeToTypeInformation('Function<{a: string, b: string}>', '', null),
295+
).toMatchSnapshot();
296+
});
291297
});
292298

293299
describe('findNextList()', () => {

src/markdown-helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@ export const safelySeparateTypeStringOn = (typeString: string, targetChar: strin
194194
current += char;
195195
switch (char) {
196196
case '<':
197+
case '{':
197198
depth++;
198199
break;
199200
case '>':
201+
case '}':
200202
depth--;
201203
break;
202204
}

0 commit comments

Comments
 (0)