Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.mts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function extractPropertiesFromObjectParam(param: ParameterDeclaration) {
* TODO: Replace with a more robust solution.
*/
export function getShortType(type: string) {
return type.replaceAll(/import\(".*"\)\./g, "");
return type.replaceAll(/import\(".*?"\)\./g, "");
}

export function getClassesFromService(node: SourceFile) {
Expand Down
9 changes: 9 additions & 0 deletions tests/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ describe("common", () => {
const result = getShortType(type);
expect(result).toBe("MyType");
});

test("json", () => {
const type =
'{ import1?: import("/path/to/import1").Import1; import2: import("/path/to/import2").Import2; import3: import("/path/to/import3").Import3; }';
const result = getShortType(type);
expect(result).toBe(
"{ import1?: Import1; import2: Import2; import3: Import3; }",
);
});
});

test("formatOptions - converts string boolean to boolean (false)", () => {
Expand Down