Skip to content

Commit 9fa9f6e

Browse files
authored
Check result type before using in operator (openapi-ts#1724)
* Check `result` type before using `in` operator * Create serious-days-live.md
1 parent 12b71fa commit 9fa9f6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/transform/schema-object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function transformSchemaObjectCore(schemaObject: SchemaObject, options: Transfor
269269
if ("type" in schemaObject && schemaObject.type) {
270270
if (typeof options.ctx.transform === "function") {
271271
const result = options.ctx.transform(schemaObject, options);
272-
if (result) {
272+
if (result && typeof result === "object") {
273273
if ("schema" in result) {
274274
if (result.questionToken) {
275275
return ts.factory.createUnionTypeNode([result.schema, UNDEFINED]);
@@ -470,7 +470,7 @@ function transformSchemaObjectCore(schemaObject: SchemaObject, options: Transfor
470470

471471
if (typeof options.ctx.transform === "function") {
472472
const result = options.ctx.transform(v as SchemaObject, options);
473-
if (result) {
473+
if (result && typeof result === "object") {
474474
if ("schema" in result) {
475475
type = result.schema;
476476
optional = result.questionToken ? QUESTION_TOKEN : optional;

0 commit comments

Comments
 (0)