Skip to content

Commit b45bfae

Browse files
committed
✨ feat: implement optional prefixes for generated type identifiers
1 parent 5ebbea1 commit b45bfae

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ const configSchema = Type.Object(
6767
* What file extension, if any, to add to src file imports. Set to ".js" to support nodenext module resolution
6868
*/
6969
importFileExtension: Type.String({ default: "" }),
70+
/**
71+
* The prefix to add to exported types
72+
*/
73+
exportedTypePrefix: Type.String({ default: "" }),
7074
},
7175
{ additionalProperties: false },
7276
);

src/generators/wrappers/composite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import { getConfig } from "../../config";
44
export function makeComposite(inputModels: string[]) {
55
return `${
66
getConfig().typeboxImportVariableName
7-
}.Composite([${inputModels.join(",")}], ${generateTypeboxOptions()})\n`;
7+
}.Composite([${inputModels.map((i) => `${getConfig().exportedTypePrefix}${i}`).join(",")}], ${generateTypeboxOptions()})\n`;
88
}

src/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type ProcessedModel = {
2323
function convertModelToStandalone(
2424
input: Pick<ProcessedModel, "name" | "stringRepresentation">,
2525
) {
26-
return `export const ${input.name} = ${input.stringRepresentation}\n`;
26+
return `export const ${getConfig().exportedTypePrefix}${input.name} = ${input.stringRepresentation}\n`;
2727
}
2828

2929
function typepoxImportStatement() {

0 commit comments

Comments
 (0)