Skip to content

Commit 196718b

Browse files
committed
adopting cr comments
1 parent 5a46974 commit 196718b

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

packages/sdk/src/ts-schema-generator.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,24 +1066,31 @@ export class TsSchemaGenerator {
10661066
}
10671067

10681068
private generateSchemaTypeImport(schemaObject: boolean, schemaType: boolean) {
1069-
const toImport = [
1070-
...(schemaObject ? ['schema as $schema'] : []),
1071-
...(schemaType ? ['type SchemaType as $Schema'] : []),
1072-
];
1069+
const importSpecifiers = [];
1070+
1071+
if (schemaObject) {
1072+
importSpecifiers.push(
1073+
ts.factory.createImportSpecifier(
1074+
false,
1075+
ts.factory.createIdentifier('schema'),
1076+
ts.factory.createIdentifier('$schema'),
1077+
),
1078+
);
1079+
}
1080+
1081+
if (schemaType) {
1082+
importSpecifiers.push(
1083+
ts.factory.createImportSpecifier(
1084+
true,
1085+
ts.factory.createIdentifier('SchemaType'),
1086+
ts.factory.createIdentifier('$Schema'),
1087+
),
1088+
);
1089+
}
10731090

10741091
return ts.factory.createImportDeclaration(
10751092
undefined,
1076-
ts.factory.createImportClause(
1077-
false,
1078-
undefined,
1079-
ts.factory.createNamedImports([
1080-
ts.factory.createImportSpecifier(
1081-
false,
1082-
undefined,
1083-
ts.factory.createIdentifier(toImport.join(', ')),
1084-
),
1085-
]),
1086-
),
1093+
ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(importSpecifiers)),
10871094
ts.factory.createStringLiteral('./schema'),
10881095
);
10891096
}

0 commit comments

Comments
 (0)