Skip to content

Commit 4e5961b

Browse files
committed
feat(code-gen): disable array auto-conversion types for the TS target
On complex types with a lot of array conversion types in there, TS is getting really slow. So let's disable it for now. We may want to completely remove this feature in the future.
1 parent 61a4310 commit 4e5961b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/code-gen/src/types/optionality.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ export function typesHasDifferentTypeAfterValidators(generateContext, type) {
9090
hasOptionalityDifferences || inputOptionality !== outputOptionality;
9191

9292
if (
93-
nestedType.type === "array" ||
93+
// tsc performance tanks because of array auto-conversion, so it's disabled. Which
94+
// means that optional & non-optional types don't have a diff
95+
(generateContext.options.targetLanguage !== "ts" &&
96+
nestedType.type === "array") ||
9497
nestedType.type === "number" ||
9598
nestedType.type === "date" ||
9699
nestedType.type === "boolean"

packages/code-gen/src/types/typescript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ export function typesTypescriptFormatType(
295295
fileWriteInline(file, `)`);
296296
fileWriteInline(file, `[]`);
297297

298-
if (options.validatorState === "input") {
298+
if (
299+
// TS performance tanks because of auto-array conversion, so this is disabled
300+
generateContext.options.targetLanguage !== "ts" &&
301+
options.validatorState === "input"
302+
) {
299303
if (type.values.type !== "anyOf") {
300304
// AnyOf always starts with a `|`.
301305
fileWriteInline(file, "|");

0 commit comments

Comments
 (0)